package com.mvd.app.ac_wenzhou;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AlertDialog;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.kongzue.dialog.interfaces.OnMenuItemClickListener;
import com.kongzue.dialog.util.TextInfo;
import com.kongzue.dialog.v3.BottomMenu;
import com.kongzue.dialog.v3.MessageDialog;
import com.kongzue.dialog.v3.TipDialog;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.base.Request;
import com.mvd.app.R;
import com.mvd.app.ac2020.VideoListActivity;
import com.mvd.app.activity.BaseActivity;
import com.mvd.app.activity.WaiJianPhotoActivity;
import com.mvd.app.activity.WaiJianResultActivity;
import com.mvd.app.activitys.ErrorMsgActivity;
import com.mvd.app.activitys.OnlineActivity;
import com.mvd.app.activitys.SignatureActivity;
import com.mvd.app.activitys.UniquenessActivity;
import com.mvd.app.activitys.WaiJianItemActivity;
import com.mvd.app.activitys.Wai_6M_PhotoActivity;
import com.mvd.app.application.BaseApplication;
import com.mvd.app.commons.CommonUtils;
import com.mvd.app.commons.Constants;
import com.mvd.app.commons.DateUtil;
import com.mvd.app.commons.JsonUtil;
import com.mvd.app.commons.PDALogUtils;
import com.mvd.app.commons.SharedPreferencesUtils;
import com.mvd.app.commons.Utils;
import com.mvd.app.commons.UtilsLog;
import com.mvd.app.commons.VehicleCheckUtils;
import com.mvd.app.model.An_Huan_Model;
import com.mvd.app.model.CarItemEndModel;
import com.mvd.app.model.CarItemStartModel;
import com.mvd.app.model.CarsInforModel;
import com.mvd.app.model.CheckItemModel;
import com.mvd.app.model.City;
import com.mvd.app.model.CodeListModel;
import com.mvd.app.model.Group;
import com.mvd.app.model.HuanBaoModel;
import com.mvd.app.model.HuanItem_SE_Model;
import com.mvd.app.model.Item_1Model;
import com.mvd.app.model.Item_2Model;
import com.mvd.app.model.ItemsModel;
import com.mvd.app.model.MyChoiceModel;
import com.mvd.app.model.TypeModel;
import com.mvd.app.model.UpdateCarInfoModel;
import com.mvd.app.model.UpdateCarStatusModel;
import com.mvd.app.model.VideoModel;
import com.mvd.app.model.WaiJainDataModel;
import com.mvd.app.model.WaiJianAddRecordModel;
import com.mvd.app.model.WaiJianItemModel;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.iwgang.countuptime.CountupView;

import static com.mvd.app.application.BaseApplication.checkItemModelList;
import static com.mvd.app.application.BaseApplication.myChoiceModelList;
import static com.mvd.app.application.BaseApplication.mycar_checkItemlList;

/**
 * 车辆列表跳转后的页面
 * <p>
 * 安检环保主页面
 */
public class An_Huan_HomeActivity extends BaseActivity {
    //region
    @BindView(R.id.ac_an_huan_include_an)
    LinearLayout include_an;
    @BindView(R.id.ac_an_huan_include_huan)
    LinearLayout include_huan;
    @BindView(R.id.ac_an_huan_btn_an)
    Button acAnHuanBtnAn;
    @BindView(R.id.ac_an_huan_btn_huan)
    Button acAnHuanBtnHuan;
    @BindView(R.id.include_an_chepai_haoma)
    TextView includeAnChepaiHaoma;
    @BindView(R.id.include_an_haopaileixing)
    TextView includeAnHaopaileixing;
    @BindView(R.id.include_an_cheliangleixing)
    TextView includeAnCheliangleixing;
    @BindView(R.id.include_an_vin)
    TextView includeAnVin;
    @BindView(R.id.include_an_waijianchedao)
    TextView includeAnWaijianchedao;
    @BindView(R.id.include_an_zongzhiliang)
    TextView includeAnZongzhiliang;
    @BindView(R.id.include_an_zhengbeizhiliang)
    TextView includeAnZhengbeizhiliang;
    @BindView(R.id.include_an_chewaikuochang)
    TextView includeAnChewaikuochang;
    @BindView(R.id.include_an_chewaikuokuan)
    TextView includeAnChewaikuokuan;
    @BindView(R.id.include_an_chewaikuogao)
    TextView includeAnChewaikuogao;
    @BindView(R.id.include_an_jianyanliushui)
    TextView includeAnJianyanliushui;
    @BindView(R.id.include_an_jianyancishu)
    TextView includeAnJianyancishu;
    @BindView(R.id.include_an_shiyongxingzhi)
    TextView includeAnShiyongxingzhi;
    @BindView(R.id.include_an_cheshenyanse)
    TextView includeAnCheshenyanse;
    @BindView(R.id.include_an_cancle)
    Button includeAnCancle;
    @BindView(R.id.include_huan_huanbao_jianyan_liushuihao)
    EditText includeHuanHuanbaoJianyanLiushuihao;
    @BindView(R.id.include_huan_jianyan_jigou_bianhao)
    EditText includeHuanJianyanJigouBianhao;
    @BindView(R.id.include_huan_jiancexian_bianhao)
    TextView includeHuanJiancexianBianhao;
    @BindView(R.id.include_huan_jianyan_cishu)
    EditText includeHuanJianyanCishu;
    @BindView(R.id.include_huan_jiance_cheliang_leibie)
    EditText includeHuanJianceCheliangLeibie;
    @BindView(R.id.lay_line_ac_car_details_waijianchedao)
    LinearLayout layLineAcCarDetailsWaijianchedao;
    @BindView(R.id.include_huan_waijian_yuan)
    EditText includeHuanWaijianYuan;
    @BindView(R.id.include_huan_waijianyuan_shenfenzhenghao)
    EditText includeHuanWaijianyuanShenfenzhenghao;
    @BindView(R.id.include_huan_waiguan_jianyan_jielun)
    EditText includeHuanWaiguanJianyanJielun;
    @BindView(R.id.include_huan_waiguan_jianyan_jielun_miaoshu)
    EditText includeHuanWaiguanJianyanJielunMiaoshu;
    @BindView(R.id.include_huan_haopai_haoma)
    EditText includeHuanHaopaiHaoma;
    @BindView(R.id.include_huan_haopai_zhonglei)
    EditText includeHuanHaopaiZhonglei;
    @BindView(R.id.include_huan_haopai_yanse)
    EditText includeHuanHaopaiYanse;
    @BindView(R.id.include_huan_cheliang_shibie_daihao)
    EditText includeHuanCheliangShibieDaihao;
    @BindView(R.id.include_huan_cheliang_leixing)
    EditText includeHuanCheliangLeixing;
    @BindView(R.id.include_huan_ranliao_zhonglei)
    EditText includeHuanRanliaoZhonglei;
    @BindView(R.id.include_huan_denglu_shijian)
    EditText includeHuanDengluShijian;
    @BindView(R.id.include_huan_waijian_kaishi_shijian)
    EditText includeHuanWaijianKaishiShijian;
    @BindView(R.id.include_huan_waijian_kaishi_huanbao_jianguan_pingtai_shijian)
    EditText includeHuanWaijianKaishiHuanbaoJianguanPingtaiShijian;
    @BindView(R.id.include_huan_waijian_jieshu_shijian)
    EditText includeHuanWaijianJieshuShijian;
    @BindView(R.id.include_huan_waijian_jieshu_huanbao_jianguan_pingtai_shijian)
    EditText includeHuanWaijianJieshuHuanbaoJianguanPingtaiShijian;
    @BindView(R.id.include_huan_xingshi_lichengshu)
    EditText includeHuanXingshiLichengshu;
    @BindView(R.id.include_huan_h_4)
    TextView includeHuanH4;
    @BindView(R.id.include_huan_h_5)
    TextView includeHuanH5;
    @BindView(R.id.include_huan_h_6)
    TextView includeHuanH6;
    @BindView(R.id.include_huan_h_7)
    EditText includeHuanH7;
    @BindView(R.id.include_huan_h_8)
    TextView includeHuanH8;
    @BindView(R.id.include_huan_h_9)
    EditText includeHuanH9;
    @BindView(R.id.include_huan_h_14)
    TextView includeHuanH14;

    @BindView(R.id.include_huan_h_29)
    TextView includeHuanH29;
    @BindView(R.id.include_huan_h_30)
    TextView includeHuanH30;
    @BindView(R.id.include_huan_qudong_dianji)
    EditText includeHuanQudongDianji;
    @BindView(R.id.include_huan_chuneng_zhuangzhi_xinghao)
    EditText includeHuanChunengZhuangzhiXinghao;
    @BindView(R.id.include_huan_dianchi_rongliang)
    EditText includeHuanDianchiRongliang;
    @BindView(R.id.include_huan_qudong_dianji_gonglv)
    EditText includeHuanQudongDianjiGonglv;
    @BindView(R.id.include_huan_dianchi_dianya)
    EditText includeHuanDianchiDianya;
    @BindView(R.id.include_huan_shifou_you_sanyuan_cuihuaqi)
    TextView includeHuanShifouYouSanyuanCuihuaqi;
    @BindView(R.id.include_huan_sanyuan_cuihuaqi_xinghao)
    EditText includeHuanSanyuanCuihuaqiXinghao;
    @BindView(R.id.include_huan_huo_xing_tan)
    TextView includeHuanHuoXingTan;
    @BindView(R.id.include_huan_ranyou_zhengfa_kongzhi)
    TextView includeHuanRanyouZhengfaKongzhi;
    @BindView(R.id.include_huan_e_ding_gonglv)
    EditText includeHuanEDingGonglv;
    @BindView(R.id.include_huan_e_ding_zhuansu)
    EditText includeHuanEDingZhuansu;
    @BindView(R.id.include_huan_shifou_dpf)
    TextView includeHuanShifouDpf;
    @BindView(R.id.include_huan_dpf_xinghao)
    EditText includeHuanDpfXinghao;
    @BindView(R.id.include_huan_shifou_scr)
    TextView includeHuanShifouScr;
    @BindView(R.id.include_huan_scr_xinghao)
    EditText includeHuanScrXinghao;
    @BindView(R.id.include_huan_shifou_doc)
    TextView includeHuanShifouDoc;
    @BindView(R.id.include_huan_doc_xinghao)
    EditText includeHuanDocXinghao;
    @BindView(R.id.include_huan_shifou_poc)
    TextView includeHuanShifouPoc;
    @BindView(R.id.include_huan_poc_xinghao)
    EditText includeHuanPocXinghao;
    @BindView(R.id.include_huan_bianhao)
    EditText includeHuanBianhao;
    @BindView(R.id.include_huan_yizhi)
    EditText includeHuanYizhi;
    @BindView(R.id.include_huan_shifou_yizhi)
    EditText includeHuanShifouYizhi;
    @BindView(R.id.include_huan_paifang_jieduan)
    EditText includeHuanPaifangJieduan;
    @BindView(R.id.include_huan_cancle)
    Button includeHuanCancle;
    @BindView(R.id.ac_an_huan_btn_xiangmu_jieshu)
    Button acAnHuanBtnXiangmuJieshu;
    @BindView(R.id.include_huan_dache_digou_jaince)
    Button includeHuanDacheDigouJaince;
    @BindView(R.id.include_huan_dache_digou_kaishi)
    Button includeHuanDacheDigouKaishi;
    @BindView(R.id.include_huan_dache_jaince_sss)
    RelativeLayout includeHuanDacheJainceSss;
    @BindView(R.id.ac_an_huan_btn_paizhao_an_huan)
    Button acAnHuanBtnPaizhaoAnHuan;
    //    @BindView(R.id.include_huan_start_123)
//    Button includeHuanStart123;
    @BindView(R.id.include_an_start)
    Button includeAnStart;
    @BindView(R.id.include_an_lianwang_chaxun)
    Button includeAnLianwangChaxun;
    @BindView(R.id.include_an_weiyixing)
    Button includeAnWeiyixing;
    @BindView(R.id.include_an_dajiahao)
    Button includeAnDajiahao;
    @BindView(R.id.include_an_tezhengcanshu)
    Button includeAnTezhengcanshu;
    @BindView(R.id.ac_an_huan_btn_6m)
    Button acAnHuanBtn6m;
    @BindView(R.id.include_huan_paizhao)
    Button includeHuanPaizhao;
    @BindView(R.id.include_an_memo)
    EditText includeAnEtMemo;
    @BindView(R.id.include_an_memo_tv)
    TextView includeAnTvMemo;
    @BindView(R.id.include_an_luntaiguige)
    TextView includeAnLuntaiguige;
    @BindView(R.id.include_an_view_mm_33)
    TextView includeAnViewMm33;
    @BindView(R.id.ac_an_huan_btn_anjian_start)
    Button acAnHuanBtnAnjianStart;
    @BindView(R.id.include_huan_huan_start)
    Button includeHuanHuanStart;
    @BindView(R.id.include_huan_switch_more)
    Switch includeHuanSwitchMore;
    @BindView(R.id.include_huan_layout_more)
    LinearLayout includeHuanLayoutMore;
    @BindView(R.id.ac_an_huan_btn_sign)
    Button acDipandongtaiBtnSign;

    @BindView(R.id.ac_car_more_info)
    TextView acCarMoreInfo;
    @BindView(R.id.ac_car_lectronice_handbrake)
    TextView acCarLectroniceHandbrake;
    @BindView(R.id.ac_car_air_suspension)
    TextView acCarAirSuspension;
    @BindView(R.id.ac_car_suspension_form)
    TextView acCarSuspensionForm;
    @BindView(R.id.ac_car_mileage)
    EditText acCarMileage;
    @BindView(R.id.ac_car_btn_update)
    Button acCarBtnUpdate;
    @BindView(R.id.ac_car_layout_moreInfo)
    LinearLayout acCarLayoutMoreInfo;

    @BindView(R.id.ac_car_kongqi_xuanjia_zhou_shu)
    EditText acCarKongqiXuanjiaZhouShu;
    @BindView(R.id.ac_car_is_is_obd)
    TextView acCarIsIsObd;
    //endregion
    //    @BindView(R.id.include_huan_start_123)
//    Button includeHuanStart;
    private int CHECK_MODE = 0;//检测模式 0:外检  1：路试 2：底盘动态  CE 地沟
    private String Line = "1";//外检车道
    private String huanbao_Line = "01";//环保线号
    private String Item_Code = "";//F1外检,R1路试，DC底盘动态  CE 地沟
    private String Login_name = "", login_IDNumber;//当前登录的检测员的名字
    private CarsInforModel carsInforModel;
    private HuanBaoModel huanBaoModel;
    //    private An_Huan_HomeActivity instances = null;
    private An_Huan_Model an_huan_model;
    private int Is_An_Huan = 0;// 0:安检  1：环保  2:两者都有
    private WaiJainDataModel waiJainDataModel = new WaiJainDataModel();//外检上传数据model
    private WaiJainDataModel waiJainDataModel2 = new WaiJainDataModel();//外检上传数据model
    private VideoModel model = new VideoModel();
    //安检 环保项目是否已经检测过的状态记录，两者进入拍照页面状态会改变 表示已经做过
    public static boolean Is_Check_An = false, Is_Check_Huan = false;
    String EpItem = "W";
    String EpItem_B = "W";
    public static List<TypeModel> typeModelListAdapter;
    public boolean NQ_STATEMENT = false;//判定按钮是否可点击  ---联网查询
    public boolean UC_STATEMENT = false;//判定按钮是否可点击  ---唯一性
    public static boolean wai_jian_photo = false;//外检照片接口是否调用过
    int gotoTakePhotoCounts = 0;//外检上传自己后台次数
    int gotoTakePhotoCounts2 = 0;//外检上传自己后台次数
    int gotoTakePhotoCounts3 = 0;//平台次数
    private String my_item_start_time = "", my_item_end_time = "";
    private boolean is_db_data = false;//数据库是否保存数据   false:无   true：有
    List<WaiJianItemModel> books = new ArrayList<>();
    List<MyChoiceModel> myChoiceModelList_waijian = new ArrayList<>();//Code2选择的列表
    String upload_code_str = "", upload_code_str_500 = "";
    List<MyChoiceModel> code2_list_wenzhou = new ArrayList<>();
    boolean is_500 = false;
    boolean is_hege = false, is_first = true;
    boolean isSign = false;//是否已签名
    CountupView mCvCountupViewTest1;
    String EngineNOFlag;
    private boolean isMoreInfo = false; //false:更多 true:隐藏
    private String DetectionCategory;
    private An_Huan_HomeActivity instances;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_an__huan__home);
        ButterKnife.bind(this);
//        instances = this;
        instances = this;
        setBackBtn();
        setTopTitle("安检环保检测");
        typeModelListAdapter = new ArrayList<>();
        an_huan_model = (An_Huan_Model) getIntent().getSerializableExtra("model_CarsInforModel");
        UtilsLog.e("安检环保检测=车辆信息==" + an_huan_model.toString());
        String logStr2 = "\n" + "安检环保检测--车辆信息--" + "\n" + an_huan_model.toString();
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
        Is_An_Huan = an_huan_model.getIsAnHuan();
        UtilsLog.e("Is_An_Huan===" + Is_An_Huan);
        login_IDNumber = getIntent().getExtras().getString("login_IDNumber", "");
        Login_name = getIntent().getExtras().getString("Login_name", "");

        UtilsLog.e("login_IDNumber===" + login_IDNumber);
        UtilsLog.e("Login_name===" + Login_name);

        mCvCountupViewTest1 = (CountupView) findViewById(R.id.ac_waijian_tv_jishiqi_cv_CountupViewTest3);
        mCvCountupViewTest1.setTag("test1");
//        long time1 = (long) 1000;
//        mCvCountupViewTest1.start(time1);
        initMoreInfo();
        //是否大车外检地沟分开检测
        if (SharedPreferencesUtils.getIsDaCheDiGouFenLi(this)) {
            includeHuanDacheJainceSss.setVisibility(View.VISIBLE);
            EpItem_B = "B";
        } else {
            includeHuanDacheJainceSss.setVisibility(View.GONE);
            EpItem_B = "W";
        }
        if (SharedPreferencesUtils.getOpenSign(this)) {
            acDipandongtaiBtnSign.setVisibility(View.VISIBLE);
            isSign = false;
        } else {
            acDipandongtaiBtnSign.setVisibility(View.GONE);
            isSign = true;
        }
        // 0:安检  1：环保  2:两者都有
        switch (Is_An_Huan) {
            case 0:
                carsInforModel = an_huan_model.getCarsInforModel();
                UtilsLog.e("0000====carsInforModel===" + carsInforModel.toString());
                UtilsLog.e("0000====carsInforModel=EngineNOFlag==" + carsInforModel.getEngineNOFlag());
                initAnJianView();
                showAnView();
                getMyCarItms();
                acAnHuanBtnAn.setEnabled(true);
                acAnHuanBtnHuan.setEnabled(false);
                if (!TextUtils.isEmpty(carsInforModel.getOBD())) {
                    acCarIsIsObd.setText(carsInforModel.getOBD().equals("有") ? "有" : "无");
                }
//                if(!TextUtils.isEmpty(carsInforModel.getTimes())&&!(carsInforModel.getTimes()).equals("null")){
//                    int times=Integer.parseInt(carsInforModel.getTimes());
//                    if(times>1){
//                        MessageDialog.show(An_Huan_HomeActivity.this,"提示","有不合格项目(安检项目)","知道了",null);
//                    }
//                }
                break;
            case 1:
                huanBaoModel = an_huan_model.getHuanBaoModel();
                UtilsLog.e("1111====huanBaoModel===" + huanBaoModel.toString());
                showHuanView();
                acAnHuanBtnAn.setEnabled(false);
                acAnHuanBtnHuan.setEnabled(true);
                initHuanBaoView();
                includeHuanHuanStart.setVisibility(View.VISIBLE);
                break;
            case 2:
                includeHuanHuanStart.setVisibility(View.GONE);
                carsInforModel = an_huan_model.getCarsInforModel();
                huanBaoModel = an_huan_model.getHuanBaoModel();
                UtilsLog.e("2222====huanBaoModel===" + huanBaoModel.toString());
                UtilsLog.e("2222====carsInforModel===" + carsInforModel.toString());
                showAnView();
                getMyCarItms();
                acAnHuanBtnAn.setEnabled(true);
                acAnHuanBtnHuan.setEnabled(true);
                initAnJianView();
                initHuanBaoView();
                if (!TextUtils.isEmpty(carsInforModel.getOBD())) {
                    acCarIsIsObd.setText(carsInforModel.getOBD().equals("有") ? "有" : "无");
                }
//                if(!TextUtils.isEmpty(carsInforModel.getTimes())&&!(carsInforModel.getTimes()).equals("null")){
//                    int times=Integer.parseInt(carsInforModel.getTimes());
//                    if(times>1){
//                        MessageDialog.show(An_Huan_HomeActivity.this,"提示","有不合格项目(安检项目)","知道了",null);
//                    }
//                }
                break;
        }
        CHECK_MODE = BaseApplication.JIANCE_MODE;
        switch (CHECK_MODE) {
            case 0:
                Item_Code = "F1";
                break;
            case 1:
                Item_Code = "R1";
                break;
            case 2:
                Item_Code = "DC";
                break;
            case 6:
                Item_Code = "CE";
                break;
        }


//        setRightTxt("项目开始", new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//                BaseApplication.huanbao_ItemStart_time = DateUtil.currentTime2();
//                // 0:安检  1：环保  2:两者都有
//                switch (Is_An_Huan) {
//                    case 0:
//                        getDataWaiJainStart();
//                        break;
//                    case 1:
//                        getDataHuanBaoStart(EpItem);
//                        break;
//                    case 2:
//                        Handler handler = new Handler();
//                        handler.postDelayed(new Runnable() {
//                            @Override
//                            public void run() {
//                                getDataWaiJainStart();
//                            }
//                        }, 1100);//后执行Runnable中的run方法
//                        getDataHuanBaoStart(EpItem);
//                        break;
//                }
//            }
//        });

        List<TypeModel> list2 = TypeModel.listAll(TypeModel.class);

        if (list2 != null && list2.size() > 0) {
            for (int i = 0; i < list2.size(); i++) {
//                UtilsLog.e("db==333333===" + list2.get(i).toString());
                TypeModel.delete(list2.get(i));
            }
        } else {
            UtilsLog.e("db==333333===null--null--null");
        }
        //显示更多选项
        includeHuanSwitchMore.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                includeHuanSwitchMore.setChecked(isChecked);   //设置选中
                if (isChecked) {
                    includeHuanLayoutMore.setVisibility(View.VISIBLE);
                } else {
                    includeHuanLayoutMore.setVisibility(View.GONE);
                }
            }
        });

        //初始化--外检不合格项目--自动提交数据--F1_record
        an_huan_groupList = new ArrayList<Group>();
        an_huan_gridList = new ArrayList<Object>();
        an_huan_Item_2Model_list = new ArrayList<>();

    }

    private void initMoreInfo() {
        isMoreInfo = false;
        acCarMoreInfo.setText("更多");
        acCarLayoutMoreInfo.setVisibility(View.GONE);
    }

    private String[] suspension_form = new String[]{"独立悬架", "非独立悬架"};
    private String[] fou_shi_str = new String[]{"否", "是"};
    private String[] you_wu = new String[]{"有", "无"};
    private static String dzss = "0";
    private String update_lichengshu = "";//更新后的车辆里程数

    //更新车辆信息
    private void updateCarInfo() {
        WaiJianItemModel model = new WaiJianItemModel();
        String airSuspension = acCarAirSuspension.getText().toString().trim();
        String electronicHandbrake = acCarLectroniceHandbrake.getText().toString().trim();
        String suspensionForm = acCarSuspensionForm.getText().toString().trim();
        //空气悬架轴数
        String kongqi_xuanjia_zhou_shu = acCarKongqiXuanjiaZhouShu.getText().toString().trim();
        UtilsLog.e("空气悬架轴数=====" + kongqi_xuanjia_zhou_shu);
        if (!TextUtils.isEmpty(acCarMileage.getText().toString().trim())) {
            UpdateCarInfoModel uciModel = new UpdateCarInfoModel();
            if (airSuspension.equals("否")) {
                uciModel.setAirSuspension("2");//空气悬架
            } else {
                uciModel.setAirSuspension("1");//空气悬架
            }
            model.setKongqiXuanjiaZhou(kongqi_xuanjia_zhou_shu);
            if (airSuspension.equals("否")) {
                uciModel.setAirSuspension("2");//空气悬架
                model.setKongqiXuanjia("否");
            } else {
                uciModel.setAirSuspension("1");//空气悬架
                model.setKongqiXuanjia("是");
            }
            if (electronicHandbrake.equals("否")) {
                uciModel.setElectronicHandbrake("2");//电子手刹
                model.setShifouDianzikongzhi("2");
            } else {
                uciModel.setElectronicHandbrake("1");//电子手刹
                model.setShifouDianzikongzhi("1");
            }
            if (electronicHandbrake.contains("是")) {
                BaseApplication.DZSS = "是";
                dzss = "是";
                model.setShifouDianzikongzhi("是");
            } else {
                BaseApplication.DZSS = "否";
                dzss = "否";
                model.setShifouDianzikongzhi("否");
            }
            if (suspensionForm.equals("独立悬架")) {
                uciModel.setSuspensionForm("0");//悬架形式
                uciModel.setSuspensionType("0");
                model.setXuanjia_xingshi("独立悬架");
            } else {
                uciModel.setSuspensionForm("1");//悬架形式
                uciModel.setSuspensionType("1");
                model.setXuanjia_xingshi("非独立悬架");
            }
//            if (electronicHandbrake.equals("否")) {
//                uciModel.setElectronicHandbrake("2");//电子手刹
//            } else {
//                uciModel.setElectronicHandbrake("1");//电子手刹
//            }
//            if (suspensionForm.equals("独立悬架")) {
//                uciModel.setSuspensionForm("0");//悬架形式
//                uciModel.setSuspensionType("0");
//                model.setXuanjia_xingshi("独立悬架");
//            } else {
//                uciModel.setSuspensionForm("1");//悬架形式
//                uciModel.setSuspensionType("1");
//                model.setXuanjia_xingshi("非独立悬架");
//            }
            model.setOther_1(acCarMileage.getText().toString().trim());

            uciModel.setOdometer(acCarMileage.getText().toString().trim());//里程表读数
            uciModel.setPlatformSN(carsInforModel.getPlatformSN());
            uciModel.setPlateType(carsInforModel.getPlateType());
//            uciModel.setPlateNO(carsInforModel.getPlateRegion() + carsInforModel.getPlateNO());
            uciModel.setPlateRegion(carsInforModel.getPlateRegion());
            uciModel.setPlateNO(carsInforModel.getPlateNO());
            uciModel.setVIN(carsInforModel.getVIN());
            uciModel.setIsSafe("1");
            uciModel.setCarType(carsInforModel.getType());
            uciModel.setType(carsInforModel.getType());
            uciModel.setApprovedLoad(carsInforModel.getApprovedLoad());
            uciModel.setCategory(carsInforModel.getCategory());
            uciModel.setCurbWeight(carsInforModel.getCurbWeight());
            uciModel.setProductionDate(carsInforModel.getProductionDate());
            uciModel.setTotalMass(carsInforModel.getTotalMass());
            uciModel.setUseProperty(carsInforModel.getUseProperty());
            uciModel.setHeadlightSystem(carsInforModel.getHeadlightSystem());
            uciModel.setUnderpanType(carsInforModel.getUnderpanType());
            uciModel.setTotalAxis(carsInforModel.getTotalAxis());
            uciModel.setDetectCategroy(carsInforModel.getDetectionCategory());
            uciModel.setQIsSingle(carsInforModel.getQIsSingle());
            uciModel.setQueueID(carsInforModel.getQueueID());
            uciModel.setVehicleID(carsInforModel.getVehicleID());
            uciModel.setEngineNO(carsInforModel.getEngineNO());
            uciModel.setBodyColor(carsInforModel.getBodyColor());
            uciModel.setValidTill(carsInforModel.getValidTill());
            uciModel.setExpirationDate(carsInforModel.getExpirationDate());
            uciModel.setFuelType(carsInforModel.getFuelType());
            uciModel.setBrand(carsInforModel.getBrand());
            uciModel.setCarModel(carsInforModel.getCarModel());
            uciModel.setProductionEnterprises(carsInforModel.getProductionEnterprises());
            uciModel.setOwner(carsInforModel.getOwner());
            uciModel.setUsage(carsInforModel.getUsage());
            uciModel.setUseAttribute(carsInforModel.getUseAttribute());
            uciModel.setLicense(carsInforModel.getLicense());
            uciModel.setParkingAxle(carsInforModel.getParkingAxle());
            uciModel.setBrakeForce(carsInforModel.getBrakeForce());
            uciModel.setParallelModel(carsInforModel.getParallelModel());
            uciModel.setPower(carsInforModel.getPower());
            uciModel.setParkingAxis(carsInforModel.getParkingAxis());
            uciModel.setMainAxis(carsInforModel.getMainAxis());
            uciModel.setCentralAxle(carsInforModel.getCentralAxle());
            uciModel.setVehicleType(carsInforModel.getVehicleType());
            uciModel.setOBD(acCarIsIsObd.getText().toString());

            //本地数据库保存，电子手刹，里程数，空气悬架，悬架形式
            model.setCar_no(carsInforModel.getPlateRegion() +
                    carsInforModel.getPlateNO());
            model.setSN(carsInforModel.getSN());
            model.setOther_2("1");
            //转向轴数量
            if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getTurnAxis()))) {
                model.setZhuanxiangzhou(carsInforModel.getTurnAxis());
            } else {
                model.setZhuanxiangzhou("1");
            }
            model.save();


            Gson gson = new Gson();
            String jsonStr = gson.toJson(uciModel);
            String upjson_url = "{" + jsonStr.substring(1, jsonStr.length() - 1) + "}";

            String logStr = "\n" + "外检更新车辆信息----json" + "\n" +
                    "json::" + upjson_url + "\n" +
                    "URL::" + SharedPreferencesUtils.getIP(instances) + UPDATE_VEHICLE_INFO;
            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
            UtilsLog.e("外检更新车辆信息---jsonStr==" + upjson_url);
            UtilsLog.e("外检更新车辆信息---url==" + SharedPreferencesUtils.getIP(this) + UPDATE_VEHICLE_INFO);
            OkGo.<String>post(SharedPreferencesUtils.getIP(this) + UPDATE_VEHICLE_INFO)
                    .tag(this)
                    .upJson(jsonStr)
                    .execute(new StringCallback() {
                        @Override
                        public void onStart(Request<String, ? extends Request> request) {
                            super.onStart(request);
                            CommonUtils.showLoadingDialog(instances, "加载中...");
                        }

                        @Override
                        public void onSuccess(Response<String> response) {
                            CommonUtils.hideLoadingDialog(instances);
                            String result = response.body().trim();
                            UtilsLog.e("外检更新车辆信息-result==" + result);
                            UtilsLog.e("外检更新车辆信息-result=22=" + result.substring(1, result.length() -
                                    1));
                            String logStr = "\n" + "外检更新车辆信息----请求成功" + "\n" +
                                    "result::" + response.body() + "\n" +
                                    "URL::" + SharedPreferencesUtils.getIP(instances) + UPDATE_VEHICLE_INFO;
                            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                            CommonUtils.hideLoadingDialog(instances);
                            String str = result.substring(1, result.length() - 1);
                            if (!TextUtils.isEmpty(result) && !"[[]]".equals(result) && !"[{}]".equals(result)
                                    && !"[]".equals(result)) {
                                String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\",
                                        "");
                                UtilsLog.e("getDataUploadPhoto-newResult==" + newResult);
                                if ("ok".equalsIgnoreCase(newResult)) {
                                    update_lichengshu=acCarMileage.getText().toString().trim();

                                    runOnUiThread(()->{
                                        if(!TextUtils.isEmpty(update_lichengshu)&&update_lichengshu!=""){
                                            //形式里程数
                                            includeHuanXingshiLichengshu.setText(update_lichengshu);
                                        }else{
                                            //形式里程数
                                            includeHuanXingshiLichengshu.setText(huanBaoModel.getOdometer());
                                        }
                                    });
                                    Toast.makeText(instances, "更新车辆信息成功", Toast.LENGTH_LONG).show();
                                } else {
                                    Toast.makeText(instances, "更新车辆信息失败", Toast.LENGTH_SHORT).show();
                                }
                            }
                        }

                        @Override
                        public void onError(Response<String> response) {
                            super.onError(response);
                            CommonUtils.hideLoadingDialog(instances);
                            String logStr2 = "\n" + "外检更新车辆信息--onError" + "\n" +
                                    "result::" + response.body();
                            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                            UtilsLog.e("外检更新车辆信息-onError==" + response.body());
                            CommonUtils.hideLoadingDialog(instances);
                            Toast.makeText(instances, "更新车辆信息失败", Toast.LENGTH_LONG).show();
                        }
                    });
        } else {
            Toast.makeText(instances, "里程数不能为空", Toast.LENGTH_SHORT).show();
        }

    }

    @Override
    protected void onResume() {
        super.onResume();
        String logStr = "";
        if (BaseApplication.BaseApplication_buHeGeModel3List != null
                && BaseApplication.BaseApplication_buHeGeModel3List.size() > 0) {
            UtilsLog.e("BaseApplication_buHeGeModel3List==an_huan=原始数据=" + BaseApplication.BaseApplication_buHeGeModel3List.toString());
            logStr = "\n" + "BaseApplication_buHeGeModel3List==an_huan=原始数据=---" +
                    "\n" + "BaseApplication.BaseApplication_buHeGeModel3List::" + BaseApplication.BaseApplication_buHeGeModel3List.toString() + "\n";

        } else {
            logStr = "\n" + "BaseApplication_buHeGeModel3List==an_huan=原始数据=---" +
                    "\n" + "BaseApplication_buHeGeModel3List==an_huan==nullllll=" + "\n";
            UtilsLog.e("BaseApplication_buHeGeModel3List==an_huan==nullllll=");
        }
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        if (Is_An_Huan == 0 || Is_An_Huan == 2) {
            bb();
        }
        books = WaiJianItemModel.listAll(WaiJianItemModel.class);
        if (books != null && books.size() > 0) {
            is_db_data = true;
            UtilsLog.e("WaiJianPhotoActivity----本地数据库查询----不为空==" + books.toString());
            for (int i = 0; i < books.size(); i++) {
//                WaiJianItemModel.delete(books.get(i));
            }
        } else {
            is_db_data = false;
            UtilsLog.e("WaiJianPhotoActivity----本地数据库查询----空==");
        }
    }

    /**
     * 获取安检项目--不合格项目
     **/
    void getMyCarItms() {
        if (myChoiceModelList != null && myChoiceModelList.size() > 0) {
            myChoiceModelList.clear();
        }
        List<Item_2Model> Item_2Model_list = new ArrayList<>();//Code2去重后的所有数据
        Item_2Model item_2 = null;
        for (int i = 0; i < BaseApplication.checkItemModelList.size(); i++) {
//            UtilsLog.e("An_HUan_HomeActivity===BaseApplication.checkItemModelList===" + BaseApplication.checkItemModelList.get(i).toString());
            item_2 = new Item_2Model();
            item_2.setID(BaseApplication.checkItemModelList.get(i).getID());
            item_2.setCode1(BaseApplication.checkItemModelList.get(i).getCode1());
            item_2.setCode2(BaseApplication.checkItemModelList.get(i).getCode2());
            item_2.setName2(BaseApplication.checkItemModelList.get(i).getName2());
            Item_2Model_list.add(item_2);
        }
        for (int k = 0; k < Item_2Model_list.size() - 1; k++) {
            for (int j = Item_2Model_list.size() - 1; j > k; j--) {
                if (Item_2Model_list.get(j).getCode2().equals(Item_2Model_list.get(k).getCode2())) {
                    Item_2Model_list.remove(j);
                }
            }
        }
//        if (IsFirst) {
        for (int i = 0; i < Item_2Model_list.size(); i++) {
            // UtilsLog.e("an_huan_Item_2Model_list=11=" + an_huan_Item_2Model_list.get(i).toString());
            MyChoiceModel model = new MyChoiceModel();
            model.setCode2(Item_2Model_list.get(i).getCode2());
            model.setChecked(true);
            model.setName2(Item_2Model_list.get(i).getName2());
            model.setCode_key("Code2-" + Item_2Model_list.get(i).getCode2());
            model.setCode_values("0");
            myChoiceModelList.add(model);
        }
        for (int i = 0; i < Item_2Model_list.size(); i++) {
            MyChoiceModel model = new MyChoiceModel();
            model.setCode2(Item_2Model_list.get(i).getCode2());
            model.setChecked(true);
            model.setName2(Item_2Model_list.get(i).getName2());
            model.setCode_key("Code2-" + Item_2Model_list.get(i).getCode2());
            model.setCode_values("0");
            myChoiceModelList_waijian.add(model);
        }
//        for (int i = 0; i < myChoiceModelList.size(); i++) {
//            UtilsLog.e("An_HUan_HomeActivity===myChoiceModelList===" + myChoiceModelList.get(i).toString());
//        }
//        for (int i = 0; i < an_huan_Item_2Model_list.size(); i++) {
//            UtilsLog.e("An_HUan_HomeActivity===an_huan_Item_2Model_list===" + an_huan_Item_2Model_list.get(i).toString());
//        }

//        getMyCarItems();
//        }
    }

    void bb() {
        getGET_ALL_ITEMList();
        if (myChoiceModelList != null && myChoiceModelList.size() > 0) {
            myChoiceModelList.clear();
        }
//        myChoiceModelList_waijian = new ArrayList<>();
        List<Item_2Model> Item_2Model_list = new ArrayList<>();//Code2去重后的所有数据
        Item_2Model item_2 = null;
        if (BaseApplication.checkItemModelList != null &&
                BaseApplication.checkItemModelList.size() > 0) {
            for (int i = 0; i < BaseApplication.checkItemModelList.size(); i++) {
                item_2 = new Item_2Model();
                item_2.setID(BaseApplication.checkItemModelList.get(i).getID());
                item_2.setCode1(BaseApplication.checkItemModelList.get(i).getCode1());
                item_2.setCode2(BaseApplication.checkItemModelList.get(i).getCode2());
                item_2.setName2(BaseApplication.checkItemModelList.get(i).getName2());
                Item_2Model_list.add(item_2);
            }
            for (int k = 0; k < Item_2Model_list.size() - 1; k++) {
                for (int j = Item_2Model_list.size() - 1; j > k; j--) {
                    if (Item_2Model_list.get(j).getCode2().equals(Item_2Model_list.get(k).getCode2())) {
                        Item_2Model_list.remove(j);
                    }
                }
            }
            for (int i = 0; i < Item_2Model_list.size(); i++) {
                // UtilsLog.e("an_huan_Item_2Model_list=11=" + an_huan_Item_2Model_list.get(i).toString());
                MyChoiceModel model = new MyChoiceModel();
                model.setCode2(Item_2Model_list.get(i).getCode2());
                model.setChecked(true);
                model.setName2(Item_2Model_list.get(i).getName2());
                model.setCode_key("Code2-" + Item_2Model_list.get(i).getCode2());
                model.setCode_values("0");
                myChoiceModelList.add(model);
            }
        }
        getMyCarItems();
    }


    //获取所有人工检验项目接口
    private void getGET_ALL_ITEMList() {
        String url = "";
        url = GET_ALL_ITEM38900;
        String logStr = "\n" + "获取所有人工检验项目接口----" + "\n" + "URL::" +
                SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
                url + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("getGET_ALL_ITEMList---url==" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) + url);
        OkGo.<String>get(SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) + url).tag(An_Huan_HomeActivity.this)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
//                        CommonUtils.hideLoadingDialog(instances);
                        String result = response.body();
//                        UtilsLog.e("getGET_ALL_ITEMList-result==" + result);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
//                        UtilsLog.e("getGET_ALL_ITEMList-newResult==" + newResult);
//                        Logger.e("getGET_ALL_ITEMList-newResult==" + newResult);
//                        Logger.json("getGET_ALL_ITEMList-newResult=json=" + newResult);
//                        if (!TextUtils.isEmpty(newResult)  ) {
//                            if( newResult.length() > 3000&&newResult.length()<6000){
//                                UtilsLog.e("getGET_ALL_ITEMList-newResult=3000--6000===" + newResult.substring(3000, 6000));
//                            }else  if( newResult.length() > 6000&&newResult.length()<9000){
//                                UtilsLog.e("getGET_ALL_ITEMList-newResult=6000--9000===" + newResult.substring(6000, 9000));
//                            }else  if( newResult.length() > 9000&&newResult.length()<12000){
//                                UtilsLog.e("getGET_ALL_ITEMList-newResult=9000--12000===" + newResult.substring(9000, 12000));
//                            }else  if( newResult.length() > 12000&&newResult.length()<15000){
//                                UtilsLog.e("getGET_ALL_ITEMList-newResult=12000--15000===" + newResult.substring(12000, 15000));
//                            }else  if( newResult.length() > 15000&&newResult.length()<18000){
//                                UtilsLog.e("getGET_ALL_ITEMList-newResult=15000--18000===" + newResult.substring(15000, 18000));
//                            }else{
//                                UtilsLog.e("getGET_ALL_ITEMList-newResult=>>>18000===" + newResult.substring(18000, newResult.length()));
//                            }
//                        }

                        String logStr = "\n" + "获取所有人工检验项目接口----onSuccess" + "\n" + "result::" + response.body() + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        if (!TextUtils.isEmpty(newResult) && !"[[]]".equals(newResult) && !"[{}]".equals
                                (newResult) && !"[]".equals(result)) {
                            List<CheckItemModel> checkItemModelList2 = new ArrayList<>();
                            myChoiceModelList_waijian = new ArrayList<>();
                            checkItemModelList = new ArrayList<CheckItemModel>();
                            checkItemModelList = JsonUtil.stringToArray(newResult, CheckItemModel[].class);
                            checkItemModelList2 = JsonUtil.stringToArray(newResult, CheckItemModel[].class);

                            List<Item_2Model> Item_2Model_list = new ArrayList<>();//Code2去重后的所有数据
                            Item_2Model item_2 = null;
                            if (checkItemModelList2 != null &&
                                    checkItemModelList2.size() > 0) {
                                for (int i = 0; i < checkItemModelList2.size(); i++) {
                                    item_2 = new Item_2Model();
                                    item_2.setID(checkItemModelList2.get(i).getID());
                                    item_2.setCode1(checkItemModelList2.get(i).getCode1());
                                    item_2.setCode2(checkItemModelList2.get(i).getCode2());
                                    item_2.setName2(checkItemModelList2.get(i).getName2());
                                    Item_2Model_list.add(item_2);
                                }
                                for (int k = 0; k < Item_2Model_list.size() - 1; k++) {
                                    for (int j = Item_2Model_list.size() - 1; j > k; j--) {
                                        if (Item_2Model_list.get(j).getCode2().equals(Item_2Model_list.get(k).getCode2())) {
                                            Item_2Model_list.remove(j);
                                        }
                                    }
                                }
                                for (int i = 0; i < Item_2Model_list.size(); i++) {
                                    MyChoiceModel model = new MyChoiceModel();
                                    model.setCode2(Item_2Model_list.get(i).getCode2());
                                    model.setChecked(true);
                                    model.setName2(Item_2Model_list.get(i).getName2());
                                    model.setCode_key("Code2-" + Item_2Model_list.get(i).getCode2());
                                    model.setCode_values("0");
                                    myChoiceModelList_waijian.add(model);
                                }
                            } else {
                                Toast.makeText(An_Huan_HomeActivity.this, "获取所有人工检测项目内容失败，请重试",
                                        Toast.LENGTH_LONG).show();
                            }
                        } else {
//                            Toast.makeText(instances, getResources().getString(R.string.network_error),
// Toast.LENGTH_LONG).show();
                            UtilsLog.e("getGET_ALL_ITEMList-result==" + "没有数据");
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
//                        CommonUtils.hideLoadingDialog(instances);
                        UtilsLog.e("getGET_ALL_ITEMList-onError==" + response.body());
                        String logStr = "\n" + "获取所有人工检验项目接口----onError" + "\n" + "result::" + response.body() + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        Toast.makeText(An_Huan_HomeActivity.this, getResources().getString(R.string.services_error), Toast
                                .LENGTH_LONG).show();
                    }
                });
    }

    void initHuanBaoView() {
        //环保检验流水号
        includeHuanHuanbaoJianyanLiushuihao.setText(huanBaoModel.getSN());
        //检验机构编号
        includeHuanJianyanJigouBianhao.setText(huanBaoModel.getPlatformSN());
        //检测线编号(外检)
        includeHuanJiancexianBianhao.setText("01");
        //检验次数
        includeHuanJianyanCishu.setText(huanBaoModel.getTimes());
        //检验车辆类别
        includeHuanJianceCheliangLeibie.setText(huanBaoModel.getDetectionCategory());
        //外检员
        includeHuanWaijianYuan.setText(huanBaoModel.getAppearanceInspector());
        //外检员身份证号
//        includeHuanWaijianyuanShenfenzhenghao.setText(huanBaoModel.get);
        //外观检验结论
//        includeHuanWaiguanJianyanJielun.setText(huanBaoModel.getSN());
        //外观检验结论描述
//        includeHuanWaiguanJianyanJielunMiaoshu.setText(huanBaoModel.getSN());
        //号牌号码
        includeHuanHaopaiHaoma.setText(huanBaoModel.getPlateRegion() +
                huanBaoModel.getPlateNO() + huanBaoModel.getPlateExtra());
        //号牌种类
        includeHuanHaopaiZhonglei.setText(huanBaoModel.getPlateTypeName());
        //号牌颜色
        includeHuanHaopaiYanse.setText(huanBaoModel.getPlateColor());
        //车辆识别代号
        includeHuanCheliangShibieDaihao.setText(huanBaoModel.getVIN());
        //车辆类型
        includeHuanCheliangLeixing.setText(String.valueOf(huanBaoModel.getTypeName()));
        //燃料种类
        includeHuanRanliaoZhonglei.setText(huanBaoModel.getFuelTypeName());
        //登录时间
        includeHuanDengluShijian.setText(huanBaoModel.getDetectDate());
        //变速箱
//        includeHuanH4.setText(shou_dong_str[0]);
        includeHuanH4.setText(huanBaoModel.getTransmissionTypeName());
        //  外检员姓名，身份证
        if (!TextUtils.isEmpty(Login_name) && !TextUtils.isEmpty(login_IDNumber)) {
            includeHuanWaijianYuan.setText(Login_name);
            includeHuanWaijianyuanShenfenzhenghao.setText(login_IDNumber);
        }
        UtilsLog.e("hunbao----形式里程数" + huanBaoModel.getOdometer());
        if(!TextUtils.isEmpty(update_lichengshu)&&update_lichengshu!=""){
            //形式里程数
            includeHuanXingshiLichengshu.setText(update_lichengshu);
        }else{
            //形式里程数
            includeHuanXingshiLichengshu.setText(huanBaoModel.getOdometer());
        }

        //额定功率
        includeHuanEDingGonglv.setText(huanBaoModel.getPower());
        //额定转速
        includeHuanEDingZhuansu.setText(huanBaoModel.getMotoRate());
        //进气方式
        if (huanBaoModel.getAirAdmission().equals("0")) {
            includeHuanH5.setText("自然吸气");
        } else {
            includeHuanH5.setText("涡轮增压");
        }
//        includeHuanH5.setText(jin_qi_fang_shi_str[0]);
        //驱动方式
        if (huanBaoModel.getDriverType().equals("0")) {
            //前驱
            includeHuanH6.setText("前驱");
        } else if (huanBaoModel.getDriverType().equals("1")) {
//后驱
            includeHuanH6.setText("后驱");
        } else if (huanBaoModel.getDriverType().equals("2")) {
//全时四驱
            includeHuanH6.setText("全时四驱");
        } else if (huanBaoModel.getDriverType().equals("3")) {
//分时四驱
            includeHuanH6.setText("分时四驱");
        }
//        includeHuanH6.setText(qu_dong_fang_shi_str[0]);

        //气缸数  includeHuanH7
        if (!TextUtils.isEmpty(huanBaoModel.getCylinder())) {
            includeHuanH7.setText(huanBaoModel.getCylinder());
        }
        //燃油形式
//        includeHuanH8.setText(ran_you_lei_xing_str[0]);
        includeHuanH8.setText(huanBaoModel.getFuelSupplyName());
//
//        if (ranyouxingshi.contains("化油器")) {
//            includeHuanH8.setText("化油器");
//        } else if (ranyouxingshi.contains("电喷")||ranyouxingshi.contains("直喷")) {
//            includeHuanH8.setText("电喷,直喷");
//        } else if (ranyouxingshi.contains("单体泵")||ranyouxingshi.contains("直列泵")||ranyouxingshi.contains("机械泵")) {
//            includeHuanH8.setText("单体泵,直列泵");
//        } else if (ranyouxingshi.contains("高压共轨")) {
//            includeHuanH8.setText("高压共轨");
//        } else {
//            includeHuanH8.setText("泵喷嘴");
//        }

        //排气管数量   includeHuanH9
        //是否有OBD接口
        if (huanBaoModel.getOBD().equals("有")) {
            includeHuanH14.setText("是");
        } else {
            includeHuanH14.setText("否");
        }
//        includeHuanH14.setText(shi_fou_str[0]);
        //是否混动车
        if (huanBaoModel.getFuelType().equalsIgnoreCase("O")) {
            includeHuanH29.setText("是");

        } else {
            includeHuanH29.setText("否");
        }
        if (!TextUtils.isEmpty(huanBaoModel.getMotorModel())) {
            includeHuanQudongDianji.setText(huanBaoModel.getMotorModel());
        }
        if (!TextUtils.isEmpty(huanBaoModel.getEnergyModel())) {
            includeHuanChunengZhuangzhiXinghao.setText(huanBaoModel.getEnergyModel());
        }
        if (!TextUtils.isEmpty(huanBaoModel.getBatteryCapacity())) {
            //电池容量：BatteryCapacity
            includeHuanDianchiRongliang.setText(huanBaoModel.getBatteryCapacity());
        }
//        //是否有dpf
//        includeHuanShifouDpf.setText(shi_fou_str[0]);
//        //是否有scr
//        includeHuanShifouScr.setText(shi_fou_str[0]);
        if (!huanBaoModel.getSCR().equals("无")) {
            //SCR型号：SCRModel
            includeHuanScrXinghao.setText(huanBaoModel.getSCRModel());
            includeHuanShifouScr.setText("有");
        } else {
            includeHuanShifouScr.setText("无");
        }
        if (!huanBaoModel.getDPF().equals("无")) {
            //DPF
            includeHuanDpfXinghao.setText(huanBaoModel.getDPFModel());
            includeHuanShifouDpf.setText("有");
        } else {
            includeHuanShifouDpf.setText("无");
        }
        if (huanBaoModel.getTWC().equals("1")) {
            //TWC三元催化器
            includeHuanSanyuanCuihuaqiXinghao.setText(huanBaoModel.getTWCModel());
            includeHuanShifouYouSanyuanCuihuaqi.setText("有");
        } else {
            includeHuanShifouYouSanyuanCuihuaqi.setText("无");
        }

//        includeHuanH29.setText(shi_fou_str[0]);
        //是否纯燃油模式
        if (huanBaoModel.getFuelType().equalsIgnoreCase("O")) {
            includeHuanH30.setText("是");
        } else {
            includeHuanH30.setText("否");
        }

//        //是否有三元催化器
//        includeHuanShifouYouSanyuanCuihuaqi.setText(shi_fou_str[0]);
        //是否有活性炭
        includeHuanHuoXingTan.setText(shi_fou_str[0]);
        //汽油器燃油蒸发控制系统是否正常
        includeHuanRanyouZhengfaKongzhi.setText(shi_fou_str[0]);
//        //是否有dpf
//        includeHuanShifouDpf.setText(shi_fou_str[0]);
//        //是否有scr
//        includeHuanShifouScr.setText(shi_fou_str[0]);
        //是否有doc
        includeHuanShifouDoc.setText(shi_fou_str[0]);
        //是否有poc
        includeHuanShifouPoc.setText(shi_fou_str[0]);
        //随车清单装置是否一致
        includeHuanShifouYizhi.setText(shi_fou_str[0]);

        //排放阶段
//        1 国1
//        2 国2
//        3 国3
//        4 国4
//        5 国5
//        6a 国6a
//        6b 国6b
//        D 零排放（电动车）
        String paifang = huanBaoModel.getApprovalValue();
        includeHuanPaifangJieduan.setText(paifang);
//        if (paifang.contains("1")) {
//            includeHuanPaifangJieduan.setText("国1");
//        } else if (paifang.contains("2")) {
//            includeHuanPaifangJieduan.setText("国2");
//        } else if (paifang.contains("3")) {
//            includeHuanPaifangJieduan.setText("国3");
//        } else if (paifang.contains("4")) {
//            includeHuanPaifangJieduan.setText("国4");
//        } else if (paifang.contains("5")) {
//            includeHuanPaifangJieduan.setText("国5");
//        } else if (paifang.contains("6a")) {
//            includeHuanPaifangJieduan.setText("国6a");
//        } else if (paifang.contains("6b")) {
//            includeHuanPaifangJieduan.setText("国6b");
//        } else if (paifang.contains("D")) {
//            includeHuanPaifangJieduan.setText("电动车");
//        }
//        includeHuanPaifangJieduan.setText(huanBaoModel.getApprovalValue());
        UtilsLog.e("排放标准===" + huanBaoModel.getApprovalValue());
    }

    private void initAnJianView() {
        UtilsLog.e("anjian----形式里程数" + carsInforModel.getOdometer());
        includeAnChepaiHaoma.setText(carsInforModel.getPlateRegion() + carsInforModel.getPlateNO() + carsInforModel.getPlateExtra());
        includeAnHaopaileixing.setText(carsInforModel.getPlateTypeName());
        includeAnCheliangleixing.setText(String.valueOf(carsInforModel.getTypeName()));
        includeAnVin.setText(carsInforModel.getVIN());
        includeAnZongzhiliang.setText(carsInforModel.getTotalMass());
        includeAnZhengbeizhiliang.setText(carsInforModel.getTotalMass());
        includeAnChewaikuochang.setText(carsInforModel.getOutlineLength());
        includeAnChewaikuokuan.setText(carsInforModel.getOutlineWidth());
        includeAnChewaikuogao.setText(carsInforModel.getOutlineHeight());
        includeAnJianyanliushui.setText(carsInforModel.getSN());
        includeAnJianyancishu.setText(carsInforModel.getTimes());
        includeAnShiyongxingzhi.setText(carsInforModel.getUsage());
        includeAnCheshenyanse.setText(VehicleCheckUtils.CarColorsFilter(carsInforModel
                .getBodyColor()));
        //轮胎规格
        if (!TextUtils.isEmpty(carsInforModel.getTyreSize())) {
            includeAnLuntaiguige.setText(carsInforModel.getTyreSize());
        }
        if (!TextUtils.isEmpty(carsInforModel.getEngineNOFlag())) {
            includeAnEtMemo.setText(carsInforModel.getEngineNOFlag());
        }
    }

    void showAnView() {
        acAnHuanBtnAn.setTextColor(getResources().getColor(R.color.white));
        acAnHuanBtnAn.setBackground(getResources().getDrawable(R.drawable.an_huan_btn));
        acAnHuanBtnHuan.setTextColor(getResources().getColor(R.color.gray));
        acAnHuanBtnHuan.setBackground(getResources().getDrawable(R.drawable.an_huan_btn2));
        include_an.setVisibility(View.VISIBLE);
        include_huan.setVisibility(View.GONE);
    }

    void showHuanView() {
        acAnHuanBtnAn.setTextColor(getResources().getColor(R.color.gray));
        acAnHuanBtnAn.setBackground(getResources().getDrawable(R.drawable.an_huan_btn2));
        acAnHuanBtnHuan.setTextColor(getResources().getColor(R.color.white));
        acAnHuanBtnHuan.setBackground(getResources().getDrawable(R.drawable.an_huan_btn));
        include_an.setVisibility(View.GONE);
        include_huan.setVisibility(View.VISIBLE);
    }

    @OnClick({R.id.ac_an_huan_btn_an, R.id.ac_an_huan_btn_huan, R.id.include_an_chepai_haoma, R.id.include_an_haopaileixing, R.id.include_an_cheliangleixing, R.id.include_an_vin, R.id.include_an_waijianchedao, R.id.include_an_zongzhiliang, R.id.include_an_zhengbeizhiliang, R.id.include_an_chewaikuochang, R.id.include_an_chewaikuokuan, R.id.include_an_chewaikuogao, R.id.include_an_jianyanliushui, R.id.include_an_jianyancishu, R.id.include_an_shiyongxingzhi, R.id.include_an_cheshenyanse, R.id.include_an_cancle, R.id.include_huan_huanbao_jianyan_liushuihao, R.id.include_huan_jianyan_jigou_bianhao, R.id.include_huan_jiancexian_bianhao, R.id.include_huan_jianyan_cishu, R.id.include_huan_jiance_cheliang_leibie, R.id.lay_line_ac_car_details_waijianchedao, R.id.include_huan_waijian_yuan, R.id.include_huan_waijianyuan_shenfenzhenghao, R.id.include_huan_waiguan_jianyan_jielun, R.id.include_huan_waiguan_jianyan_jielun_miaoshu, R.id.include_huan_haopai_haoma, R.id.include_huan_haopai_zhonglei, R.id.include_huan_haopai_yanse, R.id.include_huan_cheliang_shibie_daihao, R.id.include_huan_cheliang_leixing, R.id.include_huan_ranliao_zhonglei, R.id.include_huan_denglu_shijian, R.id.include_huan_waijian_kaishi_shijian, R.id.include_huan_waijian_kaishi_huanbao_jianguan_pingtai_shijian, R.id.include_huan_waijian_jieshu_shijian, R.id.include_huan_waijian_jieshu_huanbao_jianguan_pingtai_shijian, R.id.include_huan_xingshi_lichengshu, R.id.include_huan_h_4, R.id.include_huan_h_5, R.id.include_huan_h_6, R.id.include_huan_h_7, R.id.include_huan_h_8, R.id.include_huan_h_9, R.id.include_huan_h_14, R.id.include_huan_h_29, R.id.include_huan_h_30, R.id.include_huan_qudong_dianji, R.id.include_huan_chuneng_zhuangzhi_xinghao, R.id.include_huan_dianchi_rongliang, R.id.include_huan_qudong_dianji_gonglv, R.id.include_huan_dianchi_dianya, R.id.include_huan_shifou_you_sanyuan_cuihuaqi, R.id.include_huan_sanyuan_cuihuaqi_xinghao, R.id.include_huan_huo_xing_tan, R.id.include_huan_ranyou_zhengfa_kongzhi, R.id.include_huan_e_ding_gonglv, R.id.include_huan_e_ding_zhuansu, R.id.include_huan_shifou_dpf, R.id.include_huan_dpf_xinghao, R.id.include_huan_shifou_scr, R.id.include_huan_scr_xinghao, R.id.include_huan_shifou_doc, R.id.include_huan_doc_xinghao, R.id.include_huan_shifou_poc, R.id.include_huan_poc_xinghao, R.id.include_huan_bianhao, R.id.include_huan_yizhi, R.id.include_huan_shifou_yizhi, R.id.include_huan_paifang_jieduan, R.id.include_huan_cancle, R.id.ac_an_huan_btn_xiangmu_jieshu, R.id.include_huan_dache_digou_jaince, R.id.include_huan_dache_digou_kaishi, R.id.ac_an_huan_btn_paizhao_an_huan, R.id.include_an_start,
            R.id.include_an_lianwang_chaxun, R.id.include_an_weiyixing, R.id.include_huan_huan_start,
            R.id.include_an_dajiahao, R.id.include_an_tezhengcanshu, R.id.ac_an_huan_btn_6m,
            R.id.include_huan_paizhao, R.id.include_an_memo_tv, R.id.ac_an_huan_btn_anjian_start,
            R.id.ac_an_huan_btn_sign, R.id.ac_car_btn_update, R.id.ac_car_more_info,
            R.id.ac_car_lectronice_handbrake, R.id.ac_car_air_suspension,
            R.id.ac_car_suspension_form, R.id.ac_car_is_is_obd
    })
    public void onViewClicked(View view) {
//         , R.id.include_huan_start_123,R.id.include_an_start
//         , R.id.ac_an_huan_btn_paizhao_an_huan
        switch (view.getId()) {
            case R.id.ac_car_is_is_obd:
                //是否有OBD
                showMyDialog(you_wu, R.id.ac_car_is_is_obd);
                break;
            case R.id.ac_an_huan_btn_sign:
                Intent intent3 = new Intent(this, SignatureActivity.class);
                intent3.putExtra("sign_carsInforModel", carsInforModel);
                intent3.putExtra("line", includeAnWaijianchedao.getText().toString().trim());
                intent3.putExtra("type", 1);
                intent3.putExtra("login_w_name", Login_name);
                startActivityForResult(intent3, 678);
                break;
            case R.id.include_huan_huan_start:
                //环保外检开始
                BaseApplication.huanbao_ItemStart_time = DateUtil.currentTime2();
                // 0:安检  1：环保  2:两者都有
                switch (Is_An_Huan) {
                    case 0:
                        getDataWaiJainStart();
                        break;
                    case 1:
                        getDataHuanBaoStart(EpItem);
                        break;
                    case 2:
                        Handler handler = new Handler();
                        handler.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                getDataWaiJainStart();
                            }
                        }, 1100);//后执行Runnable中的run方法
                        getDataHuanBaoStart(EpItem);
                        break;
                }
                break;
            case R.id.ac_an_huan_btn_anjian_start:
                //外检开始
                long time1 = (long) 1000;
                mCvCountupViewTest1.start(time1);
                BaseApplication.huanbao_ItemStart_time = DateUtil.currentTime2();
                // 0:安检  1：环保  2:两者都有
                switch (Is_An_Huan) {
                    case 0:
                        getDataWaiJainStart();
                        break;
                    case 1:
                        getDataHuanBaoStart(EpItem);
                        break;
                    case 2:
                        Handler handler = new Handler();
                        handler.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                getDataWaiJainStart();
                            }
                        }, 1100);//后执行Runnable中的run方法
                        getDataHuanBaoStart(EpItem);
                        break;
                }
                break;
            case R.id.include_an_memo_tv:
                //备注
                showMyDialog(Constants.MEMO_REASONS);
                break;
            case R.id.include_huan_paizhao:
                //环保拍照
                Line = includeAnWaijianchedao.getText().toString().trim();
                Intent an_photo22 = new Intent(this, WaiJianPhotoActivity.class);
//                an_photo.putExtra("CarDetailsActivity_CarsInforModel", carsInforModel);
                an_photo22.putExtra("CarDetailsActivity_CarsInforModel", an_huan_model);
                an_photo22.putExtra("CarDetailsActivity_acCarDetailsWaijianchedao",
                        includeAnWaijianchedao.getText().toString().trim());
//                huan_photo.putExtra("CarDetailsActivity_Line", Line);
                an_photo22.putExtra("login_w_name", Login_name);
                an_photo22.putExtra("login_IDNumber", login_IDNumber);
                an_photo22.putExtra("Is_An_Huan", Is_An_Huan);
                an_photo22.putExtra("only_huanbao", 1);
                startActivity(an_photo22);
                break;
            case R.id.ac_an_huan_btn_6m:
                // 6米以上高度拍摄照片
                Line = includeAnWaijianchedao.getText().toString().trim();
                Intent i_12 = new Intent(this, Wai_6M_PhotoActivity.class);
                i_12.putExtra("model_CarsInforModel", carsInforModel);
                i_12.putExtra("Car_Line", Line);
                i_12.putExtra("login_w_name", Login_name);
                i_12.putExtra("login_IDNumber", login_IDNumber);
                startActivity(i_12);
                break;
            case R.id.include_an_lianwang_chaxun:
                //联网查询
                Line = includeAnWaijianchedao.getText().toString().trim();
                if (carsInforModel.getNQStatus().equals("0") && NQ_STATEMENT == false) {
                    Intent i_1 = new Intent(this, OnlineActivity.class);
                    i_1.putExtra("model_CarsInforModel", carsInforModel);
                    i_1.putExtra("Car_Line", Line);
                    i_1.putExtra("login_w_name", Login_name);
                    i_1.putExtra("login_IDNumber", login_IDNumber);
                    startActivityForResult(i_1, 101);
//                    startActivity(i_1);
                } else {
                    MessageDialog.show(An_Huan_HomeActivity.this, "提示", "项目已经检测完成");
                }
                break;
            case R.id.include_an_weiyixing:
                //车辆唯一性
                Line = includeAnWaijianchedao.getText().toString().trim();
                if (carsInforModel.getUCStatus().equals("0") && UC_STATEMENT == false) {
                    Intent i_2 = new Intent(this, UniquenessActivity.class);
                    i_2.putExtra("model_CarsInforModel", carsInforModel);
                    i_2.putExtra("Car_Line", Line);
                    i_2.putExtra("login_w_name", Login_name);
                    i_2.putExtra("login_IDNumber", login_IDNumber);
                    startActivityForResult(i_2, 102);
                } else {
                    MessageDialog.show(An_Huan_HomeActivity.this, "提示", "项目已经检测完成");
                }
                break;
            case R.id.include_an_dajiahao:
                //大架号视频录制
                Line = includeAnWaijianchedao.getText().toString().trim();
                Intent intent_video_1 = new Intent(An_Huan_HomeActivity.this, VideoListActivity.class);
                intent_video_1.putExtra("CarDetailsActivity_CarsInforModel", carsInforModel);
                intent_video_1.putExtra("CarDetailsActivity_acCarDetailsWaijianchedao", Line);
                intent_video_1.putExtra("video_type", 1);
                intent_video_1.putExtra("CarDetailsActivity_Line", Line);
                startActivity(intent_video_1);
                break;
            case R.id.include_an_tezhengcanshu:
                //特征参数--车辆信息更新
                Line = includeAnWaijianchedao.getText().toString().trim();
                Intent intent = new Intent(An_Huan_HomeActivity.this, WaiJianItemActivity.class);
                intent.putExtra("CarDetailsActivity_CarsInforModel", carsInforModel);
                intent.putExtra("CarDetailsActivity_acCarDetailsWaijianchedao",
                        Line);
                intent.putExtra("CarDetailsActivity_Line", Line);
                intent.putExtra("login_w_name", Login_name);
                intent.putExtra("login_IDNumber", login_IDNumber);
                intent.putExtra("start_time", BaseApplication.W_ItemStart_time);
                startActivity(intent);
                break;
            case R.id.ac_an_huan_btn_paizhao_an_huan:
                //外检照片拍照
//                Line = includeAnWaijianchedao.getText().toString().trim();
//                Intent an_photo = new Intent(this, WaiJianPhotoActivity.class);
////                an_photo.putExtra("CarDetailsActivity_CarsInforModel", carsInforModel);
//                an_photo.putExtra("CarDetailsActivity_CarsInforModel", an_huan_model);
//                an_photo.putExtra("CarDetailsActivity_acCarDetailsWaijianchedao",
//                        includeAnWaijianchedao.getText().toString().trim());
////                huan_photo.putExtra("CarDetailsActivity_Line", Line);
//                an_photo.putExtra("login_w_name", Login_name);
//                an_photo.putExtra("login_IDNumber", login_IDNumber);
//                an_photo.putExtra("Is_An_Huan", Is_An_Huan);
//                startActivity(an_photo);
                break;
            case R.id.include_huan_dache_digou_jaince:
                //大车外检结束
                CommonUtils.showLoadingDialog(An_Huan_HomeActivity.this, "加载中...");
                getDataHuanBaoStart("A");
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                    }
                }, 2 * 1000);//后执行Runnable中的run方法
                break;
            case R.id.include_huan_dache_digou_kaishi:
                //大车地沟开始
                CommonUtils.showLoadingDialog(An_Huan_HomeActivity.this, "加载中...");
                getDataHuanBaoStart("B");
                Handler handler2 = new Handler();
                handler2.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                    }
                }, 2 * 1000);//后执行Runnable中的run方法
                break;
            case R.id.ac_an_huan_btn_an:
                showAnView();
                break;
            case R.id.ac_an_huan_btn_huan:
                showHuanView();
                break;
            case R.id.include_an_waijianchedao:
                //安检--车道号
                showHuanDialog(line_str_an, R.id.include_an_waijianchedao);
                break;
            case R.id.include_an_cancle:
                //安检项目
                Line = includeAnWaijianchedao.getText().toString().trim();
                if (Is_An_Huan == 0 || Is_An_Huan == 2) {
                    String logStr2 = "\n" + "安检项目--外检不合格项目按钮点击" + "\n";
                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                    Intent intent_2 = new Intent(this, WaiJianResultActivity.class);
                    intent_2.putExtra("WaiJianPhotoActivity_CarsInforModel", carsInforModel);
                    startActivityForResult(intent_2, 500);
//                    startActivity(intent_2);
                }
                break;
            case R.id.include_an_start:
                //安检拍照
                Line = includeAnWaijianchedao.getText().toString().trim();
                Intent an_photo = new Intent(this, WaiJianPhotoActivity.class);
//                an_photo.putExtra("CarDetailsActivity_CarsInforModel", carsInforModel);
                an_photo.putExtra("CarDetailsActivity_CarsInforModel", an_huan_model);
                an_photo.putExtra("CarDetailsActivity_acCarDetailsWaijianchedao",
                        includeAnWaijianchedao.getText().toString().trim());
//                huan_photo.putExtra("CarDetailsActivity_Line", Line);
                an_photo.putExtra("login_w_name", Login_name);
                an_photo.putExtra("login_IDNumber", login_IDNumber);
                an_photo.putExtra("Is_An_Huan", Is_An_Huan);
                startActivity(an_photo);
                break;
            case R.id.include_huan_jiancexian_bianhao:
                //检测线号   Line
                showHuanDialog(line_str, R.id.include_huan_jiancexian_bianhao);
                break;
            case R.id.include_huan_h_4:
                // 变速箱型式
                showHuanDialog(shou_dong_str, R.id.include_huan_h_4);
                break;
            case R.id.include_huan_h_5:
                // 进气方式:
                showHuanDialog(jin_qi_fang_shi_str, R.id.include_huan_h_5);
                break;
            case R.id.include_huan_h_6:
                // 驱动方式:
                showHuanDialog(qu_dong_fang_shi_str, R.id.include_huan_h_6);
                break;
            case R.id.include_huan_h_7:
                // 气缸数:
                break;
            case R.id.include_huan_h_8:
                // 燃油型式:
                showHuanDialog(ran_you_lei_xing_str, R.id.include_huan_h_8);
                break;
            case R.id.include_huan_h_9:
                // 排气管数量:
                break;
            case R.id.include_huan_h_14:
                // 是否有OBD接口
                showHuanDialog(shi_fou_str, R.id.include_huan_h_14);
                break;
            case R.id.include_huan_h_29:
                // 是否混动车
                showHuanDialog(shi_fou_str, R.id.include_huan_h_29);
                break;
            case R.id.include_huan_h_30:
                // 是否在纯燃油模式（混动车切换到纯燃油模式要求）
                showHuanDialog(shi_fou_str, R.id.include_huan_h_30);
                break;
            case R.id.include_huan_shifou_you_sanyuan_cuihuaqi:
                //是否有三元催化器
                showHuanDialog(shi_fou_str, R.id.include_huan_shifou_you_sanyuan_cuihuaqi);
                break;
            case R.id.include_huan_huo_xing_tan:
                //车辆是否有活性炭罐
                showHuanDialog(shi_fou_str, R.id.include_huan_huo_xing_tan);
                break;
            case R.id.include_huan_ranyou_zhengfa_kongzhi:
                //汽油车燃油蒸发控制系统是否正常（如软管连接）
                showHuanDialog(shi_fou_str, R.id.include_huan_ranyou_zhengfa_kongzhi);
                break;
            case R.id.include_huan_shifou_dpf:
                //是否有DPF
                showHuanDialog(shi_fou_str, R.id.include_huan_shifou_dpf);
                break;
            case R.id.include_huan_shifou_scr:
                //是否有SCR
                showHuanDialog(shi_fou_str, R.id.include_huan_shifou_scr);
                break;
            case R.id.include_huan_shifou_doc:
                //是否有DOC
                showHuanDialog(shi_fou_str, R.id.include_huan_shifou_doc);
                break;
            case R.id.include_huan_shifou_poc:
                //是否有POC
                showHuanDialog(shi_fou_str, R.id.include_huan_shifou_poc);
                break;
            case R.id.include_huan_yizhi:
                //随车清单是否网上公开一致(二维码查询结果)
                showHuanDialog(shi_fou_str, R.id.include_huan_yizhi);
                break;
            case R.id.include_huan_shifou_yizhi:
                //随车清单装置是否一致（检查车辆实际污染控制装置）
                showHuanDialog(shi_fou_str, R.id.include_huan_shifou_yizhi);
                break;
//            case R.id.include_huan_paifang_jieduan:
//                //排放阶段
//                showHuanDialog(paifang_jieduan_str, R.id.include_huan_paifang_jieduan);
//                break;
            case R.id.include_huan_cancle:
                //环保项目
                huanbao_Line = includeHuanJiancexianBianhao.getText().toString().trim();
                Line = includeAnWaijianchedao.getText().toString().trim();
                if (Is_An_Huan == 1 || Is_An_Huan == 2) {
                    Intent huan_item = new Intent(this, HuanBaoItemActivity.class);
                    huan_item.putExtra("CarDetailsActivity_CarsInforModel", huanBaoModel);
                    huan_item.putExtra("login_w_name", Login_name);
                    huan_item.putExtra("login_IDNumber", login_IDNumber);
                    if (Is_An_Huan == 1) {
                        huan_item.putExtra("huanbao_Line", huanbao_Line);
                    } else if (Is_An_Huan == 2) {
                        huan_item.putExtra("huanbao_Line", Line);
                    }
                    huan_item.putExtra("lichengshu", includeHuanXingshiLichengshu.getText().toString().trim());
                    huan_item.putExtra("biansuxiang", includeHuanH4.getText().toString().trim());
                    huan_item.putExtra("jinqifangshi", includeHuanH5.getText().toString().trim());
                    huan_item.putExtra("qudongfangshi", includeHuanH6.getText().toString().trim());
                    huan_item.putExtra("qigangshu", includeHuanH7.getText().toString().trim());
                    huan_item.putExtra("ranyouxingshi", includeHuanH8.getText().toString().trim());
                    huan_item.putExtra("paqiqiguan_shuliang", includeHuanH9.getText().toString().trim());
                    huan_item.putExtra("obd", includeHuanH14.getText().toString().trim());
                    huan_item.putExtra("hudongche", includeHuanH29.getText().toString().trim());
                    huan_item.putExtra("chunranyou", includeHuanH30.getText().toString().trim());
                    huan_item.putExtra("sanyuan_cuihuaqi", includeHuanShifouYouSanyuanCuihuaqi.getText().toString().trim());
                    huan_item.putExtra("huoxingtan", includeHuanHuoXingTan.getText().toString().trim());
                    huan_item.putExtra("ranyou_zhengfa", includeHuanRanyouZhengfaKongzhi.getText().toString().trim());
                    huan_item.putExtra("dpf", includeHuanShifouDpf.getText().toString().trim());
                    huan_item.putExtra("scr", includeHuanShifouScr.getText().toString().trim());
                    huan_item.putExtra("doc", includeHuanShifouDoc.getText().toString().trim());
                    huan_item.putExtra("poc", includeHuanShifouPoc.getText().toString().trim());
                    huan_item.putExtra("qingdan_zhuangzhi", includeHuanShifouYizhi.getText().toString().trim());

                    huan_item.putExtra("qudong_dianji_xinghao", includeHuanQudongDianji.getText().toString().trim());
                    huan_item.putExtra("chuneng_zhuangzhi_xinghao", includeHuanChunengZhuangzhiXinghao.getText().toString().trim());
                    huan_item.putExtra("dianchi_rongliang", includeHuanDianchiRongliang.getText().toString().trim());
                    huan_item.putExtra("qudong_dianji_gonglv", includeHuanQudongDianjiGonglv.getText().toString().trim());
                    huan_item.putExtra("dianchi_dianya", includeHuanDianchiDianya.getText().toString().trim());
                    huan_item.putExtra("sanyuan_xinghao", includeHuanSanyuanCuihuaqiXinghao.getText().toString().trim());
                    huan_item.putExtra("eding_gonglv", includeHuanEDingGonglv.getText().toString().trim());
                    huan_item.putExtra("eding_zhuansu", includeHuanEDingZhuansu.getText().toString().trim());
                    huan_item.putExtra("dpf_xinghao", includeHuanDpfXinghao.getText().toString().trim());
                    huan_item.putExtra("scr_xinghao", includeHuanScrXinghao.getText().toString().trim());
                    huan_item.putExtra("doc_xinghao", includeHuanDocXinghao.getText().toString().trim());
                    huan_item.putExtra("poc_xinghao", includeHuanPocXinghao.getText().toString().trim());
                    huan_item.putExtra("qingdan_yizhi", includeHuanYizhi.getText().toString().trim());
                    huan_item.putExtra("qingdan_bianhao", includeHuanBianhao.getText().toString().trim());
                    huan_item.putExtra("paifang_jieduan", includeHuanPaifangJieduan.getText().toString().trim());
                    startActivity(huan_item);
                }
                break;
//            case R.id.include_huan_start_123:
//                //环保拍照
//                huanbao_Line = includeHuanJiancexianBianhao.getText().toString().trim();
//                if (Is_An_Huan == 1 || Is_An_Huan == 2) {
//                    Intent huan_photo = new Intent(this, HuanBaoTakePhotoActivity.class);
//                    huan_photo.putExtra("CarDetailsActivity_CarsInforModel", huanBaoModel);
////                huan_photo.putExtra("CarDetailsActivity_acCarDetailsWaijianchedao",
////                        acVehicleLine.getText().toString().trim());
////                huan_photo.putExtra("CarDetailsActivity_Line", Line);
//                    huan_photo.putExtra("login_w_name", Login_name);
//                    huan_photo.putExtra("login_IDNumber", login_IDNumber);
//                    huan_photo.putExtra("huanbao_Line", huanbao_Line);
//                    startActivity(huan_photo);
//                }
//                break;
            case R.id.ac_an_huan_btn_xiangmu_jieshu:
                UtilsLog.e("外检完成--mm时间====" + mCvCountupViewTest1.getMinute());
                UtilsLog.e("外检完成--s时间====" + mCvCountupViewTest1.getSecond());
//                acAnHuanBtnXiangmuJieshu.setEnabled(false);
                huanbao_Line = includeHuanJiancexianBianhao.getText().toString().trim();
                Line = includeAnWaijianchedao.getText().toString().trim();
                BaseApplication.W_ItemEnd_time = "";
                BaseApplication.W_ItemEnd_time = DateUtil.currentTime2();
                //项目结束
//                upData();

                // 0:安检  1：环保  2:两者都有
                UtilsLog.e("Is_Check_Huan==" + Is_Check_Huan + ":::::Is_Check_An==" + Is_Check_An);
                switch (Is_An_Huan) {
                    case 0:
                        UtilsLog.e("当前车辆只有------------安检----------");
                        if (isSign) {
//                        if (!SharedPreferencesUtils.getOpenSign(An_Huan_HomeActivity.this)) {

                            // 哈尔滨地区要限值时间小车120秒，大车240秒
                            if (SharedPreferencesUtils.getDaChe(An_Huan_HomeActivity.this) && carsInforModel.getTimes().equals("1")) {
                                if (carsInforModel.getUseProperty().equals("A")
                                        && (carsInforModel.getType().contains("K3")
                                        || carsInforModel.getType().contains("K4"))
                                        ) {
                                    //非营运小型微型载客汽车--xiaoche
                                    if (mCvCountupViewTest1.getMinute() >= 2) {
                                        upData(0);
                                    } else {
                                        Toast.makeText(An_Huan_HomeActivity.this, "时间未达120s，项目无法结束", Toast.LENGTH_LONG).show();
                                    }
                                } else if (carsInforModel.getType().contains("M")
                                        || carsInforModel.getType().contains("N")
                                        ) {

                                    //摩托车、三轮汽车
                                    if (mCvCountupViewTest1.getSecond() >= 1) {
                                        upData(0);
                                    } else {
                                        Toast.makeText(An_Huan_HomeActivity.this, "时间未达90s，项目无法结束", Toast.LENGTH_LONG).show();
                                    }
                                } else {
                                    //大车
                                    if (mCvCountupViewTest1.getMinute() >= 4) {
                                        upData(0);
                                    } else {
                                        Toast.makeText(An_Huan_HomeActivity.this, "时间未达240s，项目无法结束", Toast.LENGTH_LONG).show();
                                    }
                                }
                            } else {
                                upData(0);
                            }
                        } else {
//                            Intent intent3 = new Intent(An_Huan_HomeActivity.this, SignatureActivity.class);
//                            intent3.putExtra("sign_carsInforModel", carsInforModel);
//                            intent3.putExtra("line", includeAnWaijianchedao.getText().toString().trim());
//                            intent3.putExtra("type", 1);
//                            startActivityForResult(intent3, 678);
                            TipDialog.show(An_Huan_HomeActivity.this, "还未进行签名", TipDialog.TYPE.WARNING);
                        }
                        break;
                    case 1:
                        UtilsLog.e("当前车辆只有------------环保----------");
//                        Handler handlerq = new Handler();
//                        handlerq.postDelayed(new Runnable() {
//                            @Override
//                            public void run() {
////                                updateCarStatusInfor_huanbao();
//                                getDataHuanBaoEnd();
//                            }
//                        }, 1100);//后执行Runnable中的run方法
//                        getDataHuanBaoEnd();
                        upData(1);
                        finish();
                        break;
                    case 2:
                        if (isSign) {

                            UtilsLog.e("当前车辆有-----安检++++++环保----------");
                            UtilsLog.e("Is_Check_Huan-----" + Is_Check_Huan);
                            UtilsLog.e("Is_Check_An-----" + Is_Check_An);
                            if (Is_Check_Huan == true && Is_Check_An == true) {

//                            Handler handlerqq = new Handler();
//                            handlerqq.postDelayed(new Runnable() {
//                                @Override
//                                public void run() {
//                                    updateCarStatusInfor_huanbao();
//                                }
//                            }, 1100);//后执行Runnable中的run方法
//                            updateCarStatusInfor_huanbao();
                                getDataHuanBaoEnd();
//                            upData(0);
                                UtilsLog.e("----安检---环保----都检测------");


                                // 哈尔滨地区要限值时间小车120秒，大车240秒
                                if (SharedPreferencesUtils.getDaChe(An_Huan_HomeActivity.this) && carsInforModel.getTimes().equals("1")) {
                                    if (carsInforModel.getUseProperty().equals("A")
                                            && (carsInforModel.getType().contains("K3")
                                            || carsInforModel.getType().contains("K4"))
                                            ) {
                                        //非营运小型微型载客汽车--xiaoche
                                        if (mCvCountupViewTest1.getMinute() >= 2) {
//                                        getDataHuanBaoEnd();
                                            upData(0);
                                        } else {
                                            Toast.makeText(An_Huan_HomeActivity.this, "时间未达120s，项目无法结束", Toast.LENGTH_LONG).show();
                                        }
                                    } else if (carsInforModel.getType().contains("M")
                                            || carsInforModel.getType().contains("N")
                                            ) {
                                        //摩托车、三轮汽车
                                        if (mCvCountupViewTest1.getSecond() >= 1) {
//                                        getDataHuanBaoEnd();
                                            upData(0);
                                        } else {
                                            Toast.makeText(An_Huan_HomeActivity.this, "时间未达90s，项目无法结束", Toast.LENGTH_LONG).show();
                                        }
                                    } else {
                                        //大车
                                        if (mCvCountupViewTest1.getMinute() >= 4) {
//                                        getDataHuanBaoEnd();
                                            upData(0);
                                        } else {
                                            Toast.makeText(An_Huan_HomeActivity.this, "时间未达240s，项目无法结束", Toast.LENGTH_LONG).show();
                                        }
                                    }
                                } else {
                                    upData(0);
                                }
                            } else if (Is_Check_Huan == false && Is_Check_An == true) {
                                showDialog("环保未检测");
                            } else if (Is_Check_Huan == true && Is_Check_An == false) {
                                showDialog("安检未检测");
                            } else {
                                finish();
                            }
                        } else {
                            TipDialog.show(An_Huan_HomeActivity.this, "还未进行签名", TipDialog.TYPE.WARNING);
                        }
                        break;
                }
//                finish();
                break;
            case R.id.ac_car_lectronice_handbrake:
                //是否为电子手刹
                showMyDialog(fou_shi_str, R.id.ac_car_lectronice_handbrake);
                break;
            case R.id.ac_car_air_suspension:
                //是否配备空气悬架
                showMyDialog(fou_shi_str, R.id.ac_car_air_suspension);
                break;
            case R.id.ac_car_suspension_form:
                //悬架形式
                showMyDialog(suspension_form, R.id.ac_car_suspension_form);
                break;
            case R.id.ac_car_btn_update:
                //更新车辆信息
                updateCarInfo();
                break;
            case R.id.ac_car_more_info:
                if (!isMoreInfo) {
                    isMoreInfo = true;
                    acCarMoreInfo.setText("隐藏");
                    acCarLayoutMoreInfo.setVisibility(View.VISIBLE);
                } else {
                    initMoreInfo();
                }
                break;
        }

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        BaseApplication.BaseApplication_buHeGeModel3List = new ArrayList<>();
        OkGo.getInstance().cancelTag(this);
        wai_jian_photo = false;
//        instances = null;
        Is_Check_An = false;
        Is_Check_Huan = false;
        List<WaiJianItemModel> books = WaiJianItemModel.listAll(WaiJianItemModel.class);
        if (books != null && books.size() > 0) {
            for (int i = 0; i < books.size(); i++) {
                WaiJianItemModel.delete(books.get(i));
            }
        }
    }

    //f=0  发--安检项目结束  f=1 不发--安检项目结束
    void upData(int f) {
        CommonUtils.showLoadingDialog(An_Huan_HomeActivity.this, "加载中...");
        //外检完成
        String logStr = "\n" + "点击外检完成按钮--111-";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        // 0:安检  1：环保  2:两者都有
        if (Is_An_Huan == 1) {
            waiJainDataModel.setDetection_ID(String.valueOf(huanBaoModel.getID()));
            waiJainDataModel.setFuelSupply(huanBaoModel.getFuelSupply());
            waiJainDataModel.setFuelSupplyName(huanBaoModel.getFuelSupplyName());
            waiJainDataModel.setFuleWay(huanBaoModel.getFuelSupply());
            waiJainDataModel.setGUID(huanBaoModel.getGUID());
            waiJainDataModel.setBrakeForce(huanBaoModel.getBrakeForce());
//            waiJainDataModel.setPlateNO(huanBaoModel.getPlateRegion() + huanBaoModel.getPlateNO() + huanBaoModel.getPlateExtra());
            waiJainDataModel.setPlateNO(huanBaoModel.getPlateRegion() + huanBaoModel.getPlateNO());
            waiJainDataModel.setAirAdmission(huanBaoModel.getAirAdmission());
            waiJainDataModel.setApprovedLoad(huanBaoModel.getApprovedLoad());
            waiJainDataModel.setArea(huanBaoModel.getArea());
            waiJainDataModel.setBodyColor(huanBaoModel.getBodyColor());
            waiJainDataModel.setBrand(huanBaoModel.getBrand());
            waiJainDataModel.setCarBodyType(huanBaoModel.getCarBodyType());
            waiJainDataModel.setCarID(huanBaoModel.getCarID());
            waiJainDataModel.setCarModel(huanBaoModel.getCarModel());
            waiJainDataModel.setCarTypeLevel(huanBaoModel.getCarTypeLevel());
            waiJainDataModel.setCategory(huanBaoModel.getCategory());
            waiJainDataModel.setCentralAxle(huanBaoModel.getCentralAxle());
            waiJainDataModel.setCode(huanBaoModel.getCode());
//            waiJainDataModel.setCombCarNO(huanBaoModel.getCombCarNO());
            waiJainDataModel.setCurbWeight(huanBaoModel.getCurbWeight());
            waiJainDataModel.setDetectDate(huanBaoModel.getDetectDate());
            waiJainDataModel.setDetectionCategory(huanBaoModel.getDetectionCategory());
            waiJainDataModel.setDetectionStatus(huanBaoModel.getDetectionStatus());
            waiJainDataModel.setDisplacement(huanBaoModel.getDisplacement());
            waiJainDataModel.setDriveAxle(huanBaoModel.getDriveAxle());
            waiJainDataModel.setDriverAxleWeight(huanBaoModel.getDriverAxleWeight());
            waiJainDataModel.setDriverTypeName(huanBaoModel.getDriverTypeName());
            waiJainDataModel.setDriverType(huanBaoModel.getDriverType());
            waiJainDataModel.setPlateType(huanBaoModel.getPlateType());
            waiJainDataModel.setMainAxis(huanBaoModel.getMainAxis());
            waiJainDataModel.setParkingAxle(huanBaoModel.getParkingAxle());
            waiJainDataModel.setEngineNO(huanBaoModel.getEngineNO());
            waiJainDataModel.setFuelType(huanBaoModel.getFuelType());
            waiJainDataModel.setPlateTypeName(huanBaoModel.getPlateTypeName());
            waiJainDataModel.setPlatformSN(huanBaoModel.getPlatformSN());
            waiJainDataModel.setQueueID(huanBaoModel.getQueueID());
            waiJainDataModel.setSN(huanBaoModel.getSN());
            waiJainDataModel.setStatus(huanBaoModel.getStatus());
            waiJainDataModel.setTest_times(huanBaoModel.getTimes());
            waiJainDataModel.setType(huanBaoModel.getType());
            waiJainDataModel.setVIN(huanBaoModel.getVIN());
//            if (SharedPreferencesUtils.getAddress(An_Huan_HomeActivity.this).equals("温州")) {
            model.setPlateNO(huanBaoModel.getPlateRegion()
                    + huanBaoModel.getPlateNO()
                    + huanBaoModel.getPlateExtra());
//            } else if (SharedPreferencesUtils.getAddress(An_Huan_HomeActivity.this).equals("常山")) {
//                model.setPlateNO(huanBaoModel.getPlateRegion()
//                        + huanBaoModel.getPlateNO());
//            }
//            model.setPlateNO(huanBaoModel.getPlateRegion() + huanBaoModel.getPlateNO() + huanBaoModel.getPlateExtra());
            model.setPlateType(huanBaoModel.getPlateType());
            model.setPlatformSN(huanBaoModel.getPlatformSN());
            model.setTest_times(huanBaoModel.getTimes());
            model.setDetectionID(String.valueOf(huanBaoModel.getID()));
            waiJainDataModel.setLine(includeHuanJiancexianBianhao.getText().toString().trim());
            waiJainDataModel.setTimes(huanBaoModel.getTimes());
        } else {
//            waiJainDataModel.setElectronicHandbrake(carsInforModel.getElectronicHandbrake());
            waiJainDataModel.setFuelSupply(carsInforModel.getFuelSupply());
            waiJainDataModel.setFuelSupplyName(carsInforModel.getFuelSupplyName());
            waiJainDataModel.setFuleWay(carsInforModel.getFuelSupply());
            waiJainDataModel.setTimes(carsInforModel.getTimes());
            waiJainDataModel.setLine(includeAnWaijianchedao.getText().toString().trim());
            waiJainDataModel.setDetection_ID(String.valueOf(carsInforModel.getID()));
            waiJainDataModel.setGUID(carsInforModel.getGUID());
            waiJainDataModel.setBrakeForce(carsInforModel.getBrakeForce());
//            waiJainDataModel.setPlateNO(carsInforModel.getPlateRegion() + carsInforModel.getPlateNO() + carsInforModel.getPlateExtra());
            waiJainDataModel.setPlateNO(carsInforModel.getPlateRegion() + carsInforModel.getPlateNO());
            waiJainDataModel.setAirAdmission(carsInforModel.getAirAdmission());
            waiJainDataModel.setApprovedLoad(carsInforModel.getApprovedLoad());
            waiJainDataModel.setArea(carsInforModel.getArea());
            waiJainDataModel.setBodyColor(carsInforModel.getBodyColor());
            waiJainDataModel.setBrand(carsInforModel.getBrand());
            waiJainDataModel.setCarBodyType(carsInforModel.getCarBodyType());
            waiJainDataModel.setCarID(carsInforModel.getCarID());
            waiJainDataModel.setCarModel(carsInforModel.getCarModel());
            waiJainDataModel.setCarTypeLevel(carsInforModel.getCarTypeLevel());
            waiJainDataModel.setCategory(carsInforModel.getCategory());
            waiJainDataModel.setCentralAxle(carsInforModel.getCentralAxle());
            waiJainDataModel.setCode(carsInforModel.getCode());
            waiJainDataModel.setCombCarNO(carsInforModel.getCombCarNO());
            waiJainDataModel.setCurbWeight(carsInforModel.getCurbWeight());
            waiJainDataModel.setDetectDate(carsInforModel.getDetectDate());
            waiJainDataModel.setDetectionCategory(carsInforModel.getDetectionCategory());
            waiJainDataModel.setDetectionStatus(carsInforModel.getDetectionStatus());
            waiJainDataModel.setDisplacement(carsInforModel.getDisplacement());
            waiJainDataModel.setDriveAxle(carsInforModel.getDriveAxle());
            waiJainDataModel.setDriverAxleWeight(carsInforModel.getDriverAxleWeight());
            waiJainDataModel.setDriverTypeName(carsInforModel.getDriverTypeName());
            waiJainDataModel.setDriverType(carsInforModel.getDriverType());
            waiJainDataModel.setPlateType(carsInforModel.getPlateType());
            waiJainDataModel.setMainAxis(carsInforModel.getMainAxis());
            waiJainDataModel.setParkingAxle(carsInforModel.getParkingAxle());
            waiJainDataModel.setEngineNO(carsInforModel.getEngineNO());
            waiJainDataModel.setFuelType(carsInforModel.getFuelType());
            waiJainDataModel.setPlateTypeName(carsInforModel.getPlateTypeName());
            waiJainDataModel.setPlatformSN(carsInforModel.getPlatformSN());
            waiJainDataModel.setQueueID(carsInforModel.getQueueID());
            waiJainDataModel.setSN(carsInforModel.getSN());
            waiJainDataModel.setStatus(carsInforModel.getStatus());
            waiJainDataModel.setTest_times(carsInforModel.getTimes());
            waiJainDataModel.setType(carsInforModel.getType());
            waiJainDataModel.setVIN(carsInforModel.getVIN());
//            if (SharedPreferencesUtils.getAddress(this).equals("温州")) {
//                model.setPlateNO(carsInforModel.getPlateRegion()
//                        + carsInforModel.getPlateNO()
//                        + carsInforModel.getPlateExtra());
//            } else if (SharedPreferencesUtils.getAddress(this).equals("常山")) {
            model.setPlateNO(carsInforModel.getPlateRegion()
                    + carsInforModel.getPlateNO());
//            }
//            model.setPlateNO(carsInforModel.getPlateRegion() + carsInforModel.getPlateNO() + carsInforModel.getPlateExtra());
            model.setPlateType(carsInforModel.getPlateType());
            model.setPlatformSN(carsInforModel.getPlatformSN());
            model.setTest_times(carsInforModel.getTimes());
            model.setDetectionID(String.valueOf(carsInforModel.getID()));
        }
        try {
            String name = URLDecoder.decode(Login_name, "UTF-8");
            waiJainDataModel.setAppearanceInspector(name);//检测员名字，汉字
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        waiJainDataModel.setAppearanceNo(login_IDNumber);
        waiJainDataModel.setDetectionDevID(CommonUtils.getIMEI(this));
        waiJainDataModel.setItemcode(Item_Code);
//        waiJainDataModel.setLine(includeAnWaijianchedao.getText().toString().trim());
        model.setItemcode(Item_Code);
        model.setLine(includeAnWaijianchedao.getText().toString().trim());
        String memo = includeAnEtMemo.getText().toString().trim();

        waiJainDataModel.setMemo(memo.equals("无") ? "" : memo);
        waiJainDataModel.setEngineNOFlag(memo.equals("无") ? "" : memo);
        waiJainDataModel.setRemark(memo.equals("无") ? "" : memo);
        if (!TextUtils.isEmpty(SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this))) {
            if (CommonUtils.isOnline(An_Huan_HomeActivity.this)) {
                //上传平台的数据
                waiJainDataModel.setDataType("F1");
//                getDataReportData();
                if (f == 0) {
                    if (carsInforModel.getTimes().equals("1")) {

                    }
                    uploadPlatformData_w(waiJainDataModel, f);
                } else {
                    //发环保结束
                    getDataHuanBaoEnd();
                }

//                        getDataReportData();
                String log = "EndTime=====" + BaseApplication.W_ItemEnd_time;
                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, log.getBytes());
                //视频接口上传数据
                model.setDetectionItemStartDate(BaseApplication.W_ItemStart_time);
                model.setDetectionItemEndDate(BaseApplication.W_ItemEnd_time);

                uploadVideo(model);
                String logStr33 = "\n" + "点击外检完成按钮--333-";
                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr33.getBytes());
                //让按钮变成不可点击
//                        acWaijianBtnWancheng2.setEnabled(false);
            } else {
                Toast.makeText(An_Huan_HomeActivity.this, getResources().getString(R.string.network_error), Toast
                        .LENGTH_LONG).show();
            }
        } else {
            Toast.makeText(this, "请设置IP与端口号", Toast.LENGTH_LONG).show();
        }
//                finish();
        String logStr22 = "\n" + "点击外检完成按钮--222-";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr22.getBytes());
    }

    private String[] line_str_an = new String[]{"1", "2", "3", "4", "5", "6"};
    private String[] line_str = new String[]{"01", "02", "03", "04", "05", "06"};
    private String[] shi_fou_str = new String[]{"是", "否"};
    private String[] he_ge_str = new String[]{"合格", "不合格"};
    private String[] ji_huo_str = new String[]{"激活", "未激活"};
    private String[] shou_dong_str = new String[]{"手动", "自动"};
    private String[] jin_qi_fang_shi_str = new String[]{"自然进气", "涡轮增压"};
    private String[] qu_dong_fang_shi_str = new String[]{"前驱", "后驱", "全时四驱", "分时四驱"};
    private String[] ran_you_lei_xing_str = new String[]{"化油器", "电喷、直喷", "直列泵、单体泵", "高压共轨", "泵喷嘴"};
    private String[] paifang_jieduan_str = new String[]{"国1", "国2", "国3", "国4", "国5", "国6a"};

    private void showHuanDialog(String[] str, final int id) {
//        BottomMenu bottomMenu= BottomMenu().build(this);
        BottomMenu.show(this, str, new OnMenuItemClickListener() {
            @Override
            public void onClick(String text, int index) {
                //返回参数 text 即菜单名称，index 即菜单索引
                switch (id) {
//                    case R.id.include_huan_h_1:
//                        //点火开关ON，ODB故障指示器（mil灯）是否激活:
//                        includeHuanH1.setText(text);
//                        break;
//                    case R.id.include_huan_h_2:
//                        // 起动发动机后，仪表盘OBD故障指示器（mil灯）有无点亮报警:
//                        includeHuanH2.setText(text);
//                        break;
//                    case R.id.include_huan_h_3:
//                        // OBD接口通讯是否正常
//                        includeHuanH3.setText(text);
//                        break;
                    case R.id.include_huan_h_4:
                        // 变速箱型式
                        includeHuanH4.setText(text);
                        break;
                    case R.id.include_huan_h_5:
                        // 进气方式:
                        includeHuanH5.setText(text);
                        break;
                    case R.id.include_huan_h_6:
                        // 驱动方式:
                        includeHuanH6.setText(text);
                        break;
                    case R.id.include_huan_h_7:
                        // 气缸数:
                        includeHuanH7.setText(text);
                        break;
                    case R.id.include_huan_h_8:
                        // 燃油型式:
                        includeHuanH8.setText(text);
                        break;
                    case R.id.include_huan_h_9:
                        // 排气管数量:
                        includeHuanH9.setText(text);
                        break;
//                    case R.id.include_huan_h_10:
//                        // 号牌是否一致:
//                        includeHuanH10.setText(text);
//                        break;
//                    case R.id.include_huan_h_11:
//                        // 车架号是否一致:
//                        includeHuanH11.setText(text);
//                        break;
//                    case R.id.include_huan_h_12:
//                        // 发动机号是否一致
//                        includeHuanH12.setText(text);
//                        break;
//                    case R.id.include_huan_h_13:
//                        // 品牌型号/车辆类型是否一致
//                        includeHuanH13.setText(text);
//                        break;
                    case R.id.include_huan_h_14:
                        // 是否有OBD接口
                        includeHuanH14.setText(text);
                        break;
//                    case R.id.include_huan_h_15:
//                        // 车辆水温是否正常
//                        includeHuanH15.setText(text);
//                        break;
                    case R.id.include_huan_h_29:
                        // 是否混动车
//                        includeHuanH29.setText(text);
                        break;
                    case R.id.include_huan_h_30:
                        // 是否在纯燃油模式（混动车切换到纯燃油模式要求）
//                        includeHuanH30.setText(text);
                        break;
                    case R.id.include_huan_shifou_you_sanyuan_cuihuaqi:
                        //是否有三元催化器
                        includeHuanShifouYouSanyuanCuihuaqi.setText(text);
                        break;
                    case R.id.include_huan_huo_xing_tan:
                        //车辆是否有活性炭罐
                        includeHuanHuoXingTan.setText(text);
                        break;
                    case R.id.include_huan_ranyou_zhengfa_kongzhi:
                        //汽油车燃油蒸发控制系统是否正常（如软管连接）
                        includeHuanRanyouZhengfaKongzhi.setText(text);
                        break;
//                    case R.id.include_huan_youxianggai:
//                        //车辆油箱盖是否正常使用
//                        includeHuanYouxianggai.setText(text);
//                        break;
                    case R.id.include_huan_shifou_dpf:
                        //是否有DPF
                        includeHuanShifouDpf.setText(text);
                        break;
                    case R.id.include_huan_shifou_scr:
                        //是否有SCR
                        includeHuanShifouScr.setText(text);
                        break;
                    case R.id.include_huan_shifou_doc:
                        //是否有DOC
                        includeHuanShifouDoc.setText(text);
                        break;
                    case R.id.include_huan_shifou_poc:
                        //是否有POC
                        includeHuanShifouPoc.setText(text);
                        break;
                    case R.id.include_huan_yizhi:
                        //随车清单是否网上公开一致(二维码查询结果)
                        includeHuanYizhi.setText(text);
                        break;
                    case R.id.include_huan_shifou_yizhi:
                        //随车清单装置是否一致（检查车辆实际污染控制装置）
                        includeHuanShifouYizhi.setText(text);
                        break;
//                    case R.id.include_huan_paifang_jieduan:
//                        // 排放阶段
//                        includeHuanPaifangJieduan.setText(text);
//                        break;
                    case R.id.include_an_waijianchedao:
                        //安检--车道号
                        includeAnWaijianchedao.setText(text);
                        if (Is_An_Huan == 2) {
                            includeHuanJiancexianBianhao.setText("0" + text);
                        }
                        break;
                    case R.id.include_huan_jiancexian_bianhao:
                        //环保--line--线号
                        includeHuanJiancexianBianhao.setText(text);
                        break;

                }
            }
        }).setMenuTextInfo(new TextInfo().setBold(true).setFontColor(Color.BLACK).setGravity(Gravity.CENTER));
    }
//    .setTitleTextInfo(new TextInfo().setBold(true).setFontColor(Color.RED))

    //环保---外检检测开始
    private void getDataHuanBaoStart(String EPItem) {
        UtilsLog.e("环保---项目开始=======");
        HuanItem_SE_Model model = new HuanItem_SE_Model();
        model.setSN(an_huan_model.getHuanBaoModel().getPlatformSN());
        model.setDetectionDate(an_huan_model.getDetectDate());
        if (an_huan_model.getHuanBaoModel().getDetectionCategory().equals("00")) {
            model.setDetectionCategory("2");
        } else {
            model.setDetectionCategory("1");
        }
//        model.setDetectionCategory(an_huan_model.getHuanBaoModel().getDetectionCategory().substring(1));
        model.setEPItem(EPItem);
        model.setLine(includeHuanJiancexianBianhao.getText().toString().trim());
//        model.setPlateNO(an_huan_model.getCarNo()
//                + an_huan_model.getPlateExtra());
        model.setPlateNO(an_huan_model.getCarNo());
        model.setPlateType(an_huan_model.getHuanBaoModel().getPlateType());
        model.setTimes(an_huan_model.getTimes());
        model.setVIN(an_huan_model.getHuanBaoModel().getVIN());
        Gson gson = new Gson();
        String jsonStr = gson.toJson(model);

        String upjson_url = "{" + jsonStr.substring(1, jsonStr.length() - 1) + "}";

        String logStr = "\n" + "环保-外检项目开始----json" + "\n" +
                "json::" + upjson_url + "\n" +
                "URL::" + SharedPreferencesUtils.getHuanBaoIP(An_Huan_HomeActivity.this) + Huanbao_START;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("getDataHuanBaoStart---jsonStr==" + upjson_url);
        UtilsLog.e("getDataHuanBaoStart---url==" + SharedPreferencesUtils.getHuanBaoIP(this) + Huanbao_START);
        OkGo.<String>post(SharedPreferencesUtils.getHuanBaoIP(this) + Huanbao_START)
                .tag(this)
                .upJson(upjson_url)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body().trim();
                        UtilsLog.e("getDataHuanBaoStart-result==" + result);
                        UtilsLog.e("getDataHuanBaoStart-result=22=" + result.substring(1, result.length() -
                                1));
                        String str = result.substring(1, result.length() - 1);
                        if ("ok".equalsIgnoreCase(str)) {
                            Toast.makeText(An_Huan_HomeActivity.this, "环保项目开始成功", Toast.LENGTH_LONG)
                                    .show();
                        } else {
                            Toast.makeText(An_Huan_HomeActivity.this, "环保项目开始失败，请重试", Toast.LENGTH_LONG)
                                    .show();
                        }
                        String logStr = "\n" + "环保-外检项目开始----请求成功" + "\n" +
                                "result::" + response.body() + "\n" +
                                "URL::" + SharedPreferencesUtils.getHuanBaoIP(An_Huan_HomeActivity.this) + Huanbao_START;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        String logStr2 = "\n" + "环保-外检项目开始请求--onError" + "\n" +
                                "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                        UtilsLog.e("getDataHuanBaoStart-onError==" + response.body());
//                        CommonUtils.hideLoadingDialog(instances);
                        Toast.makeText(An_Huan_HomeActivity.this, "环保项目开始失败，请重试", Toast.LENGTH_LONG)
                                .show();
                    }
                });
    }

    //环保---项目结束
    private void getDataHuanBaoEnd() {
        UtilsLog.e("环保---项目结束=======");
//        acAnHuanBtnXiangmuJieshu.setEnabled(false);
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                acAnHuanBtnXiangmuJieshu.setEnabled(true);
            }
        }, 3 * 1000);//后执行Runnable中的run方法


        HuanItem_SE_Model model = new HuanItem_SE_Model();
        model.setSN(an_huan_model.getHuanBaoModel().getPlatformSN());
        model.setDetectionDate(an_huan_model.getDetectDate());
        if (an_huan_model.getHuanBaoModel().getDetectionCategory().equals("00")) {
            model.setDetectionCategory("2");
        } else {
            model.setDetectionCategory("1");
        }
//        model.setDetectionCategory(an_huan_model.getHuanBaoModel().getDetectionCategory().substring(1));
        model.setEPItem(EpItem_B);
        model.setLine(includeHuanJiancexianBianhao.getText().toString().trim());
//        model.setPlateNO(an_huan_model.getCarNo()
//                + an_huan_model.getPlateExtra());
        model.setPlateNO(an_huan_model.getCarNo());
        model.setPlateType(an_huan_model.getHuanBaoModel().getPlateType());
        model.setTimes(an_huan_model.getTimes());
        model.setVIN(an_huan_model.getHuanBaoModel().getVIN());
        Gson gson = new Gson();
        String jsonStr = gson.toJson(model);

        String upjson_url = "{" + jsonStr.substring(1, jsonStr.length() - 1) + "}";

        String logStr = "\n" + "环保---项目结束----json" + "\n" +
                "json::" + upjson_url + "\n" +
                "URL::" + SharedPreferencesUtils.getHuanBaoIP(An_Huan_HomeActivity.this) + Huanbao_END;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("getDataHuanBaoEnd---jsonStr==" + upjson_url);
        UtilsLog.e("getDataHuanBaoEnd---url==" + SharedPreferencesUtils.getHuanBaoIP(this) + Huanbao_END);
        OkGo.<String>post(SharedPreferencesUtils.getHuanBaoIP(this) + Huanbao_END)
                .tag(this)
                .upJson(upjson_url)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body().trim();
                        UtilsLog.e("getDataHuanBaoEnd-result==" + result);
                        UtilsLog.e("getDataHuanBaoEnd-result=22=" + result.substring(1, result.length() -
                                1));
                        String str = result.substring(1, result.length() - 1);

                        String logStr = "\n" + "环保---项目结束---请求成功" + "\n" +
                                "result::" + response.body() + "\n" +
                                "URL::" + SharedPreferencesUtils.getHuanBaoIP(An_Huan_HomeActivity.this) + Huanbao_END;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        if ("ok".equalsIgnoreCase(str)) {
                            updateCarStatusInfor_huanbao();
                            Toast.makeText(An_Huan_HomeActivity.this, "环保项目结束", Toast.LENGTH_LONG)
                                    .show();
                        } else {
                            acAnHuanBtnXiangmuJieshu.setEnabled(true);
                            Toast.makeText(An_Huan_HomeActivity.this, "环保项目结束失败，请重试", Toast.LENGTH_LONG)
                                    .show();
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        String logStr2 = "\n" + "环保---项目结束--onError" + "\n" +
                                "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                        UtilsLog.e("getDataHuanBaoEnd-onError==" + response.body());
//                        CommonUtils.hideLoadingDialog(instances);
                        Toast.makeText(An_Huan_HomeActivity.this, "环保项目结束失败，请重试", Toast.LENGTH_LONG)
                                .show();
                        acAnHuanBtnXiangmuJieshu.setEnabled(true);
                    }
                });
    }

    //安检---外检检测开始
    private void getDataWaiJainStart() {
        UtilsLog.e("安检---项目开始=======");
        CarItemStartModel carItemStartModel = new CarItemStartModel();
        // 0:安检  1：环保  2:两者都有
        if (Is_An_Huan == 1) {
            carItemStartModel.setPlatformSN(huanBaoModel.getPlatformSN());
            carItemStartModel.setPlateType(huanBaoModel.getPlateType());
//        carItemStartModel.setPlateNO(carsInforModel.getPlateNO());
//            if (SharedPreferencesUtils.getAddress(An_Huan_HomeActivity.this).equals("温州")) {
//                carItemStartModel.setPlateNO(huanBaoModel.getPlateRegion()
//                        + huanBaoModel.getPlateNO()
//                        + huanBaoModel.getPlateExtra());
//            } else if (SharedPreferencesUtils.getAddress(An_Huan_HomeActivity.this).equals("常山")) {
            carItemStartModel.setPlateNO(huanBaoModel.getPlateRegion()
                    + huanBaoModel.getPlateNO());
//            }
//        data.get(position).getPlateRegion() + data.get(position).getPlateNO()
            carItemStartModel.setVIN(huanBaoModel.getVIN());
            carItemStartModel.setDetectionID(String.valueOf(huanBaoModel.getID()));
            carItemStartModel.setTest_times(huanBaoModel.getTimes());
            carItemStartModel.setLine(includeHuanJiancexianBianhao.getText().toString().trim());
        } else {
            carItemStartModel.setLine(includeAnWaijianchedao.getText().toString().trim());

            carItemStartModel.setPlatformSN(carsInforModel.getPlatformSN());
            carItemStartModel.setPlateType(carsInforModel.getPlateType());
//        carItemStartModel.setPlateNO(carsInforModel.getPlateNO());
//            carItemStartModel.setPlateNO(
//                    carsInforModel.getPlateRegion()
//                            + carsInforModel.getPlateNO()
//                            + carsInforModel.getPlateExtra()
//            );
//            if (SharedPreferencesUtils.getAddress(An_Huan_HomeActivity.this).equals("温州")) {
//                carItemStartModel.setPlateNO(carsInforModel.getPlateRegion()
//                        + carsInforModel.getPlateNO()
//                        + carsInforModel.getPlateExtra());
//            } else if (SharedPreferencesUtils.getAddress(An_Huan_HomeActivity.this).equals("常山")) {
            carItemStartModel.setPlateNO(carsInforModel.getPlateRegion()
                    + carsInforModel.getPlateNO());
//            }
//        data.get(position).getPlateRegion() + data.get(position).getPlateNO()
            carItemStartModel.setVIN(carsInforModel.getVIN());
            carItemStartModel.setDetectionID(String.valueOf(carsInforModel.getID()));
            carItemStartModel.setTest_times(carsInforModel.getTimes());
        }

        carItemStartModel.setDetectionDevID("");
        carItemStartModel.setItemCode(Item_Code);
        BaseApplication.W_ItemStart_time = "";
        BaseApplication.W_ItemStart_time = DateUtil.currentTime2();
        my_item_start_time = BaseApplication.W_ItemStart_time;
//        carItemStartModel.setDetectionItemStartDate(DateUtil.currentTime2());
        carItemStartModel.setDetectionItemStartDate(BaseApplication.W_ItemStart_time);
        Gson gson = new Gson();
        String jsonStr = gson.toJson(carItemStartModel);

//        String upjson_url = "{[" + jsonStr.substring(1, jsonStr.length() - 1) + "]}";
        String upjson_url = "{" + jsonStr.substring(1, jsonStr.length() - 1) + "}";

        String logStr = "\n" + "外检项目开始----json" + "\n" +
                "json::" + upjson_url + "\n" +
                "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) + ITEM_START;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("getDataWaiJainStart---jsonStr==" + upjson_url);
        UtilsLog.e("getDataWaiJainStart---url==" + SharedPreferencesUtils.getIP(this) + ITEM_START);
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + ITEM_START)
                .tag(this)
                .upJson(upjson_url)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
                        CommonUtils.showLoadingDialog(An_Huan_HomeActivity.this, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body().trim();
                        UtilsLog.e("getDataWaiJainStart-result==" + result);
                        UtilsLog.e("getDataWaiJainStart-result=22=" + result.substring(1, result.length() -
                                1));
                        String logStr = "\n" + "外检项目开始----请求成功" + "\n" +
                                "result::" + response.body() + "\n" +
                                "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) + ITEM_START;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                        String str = result.substring(1, result.length() - 1);
                        if ("ok".equalsIgnoreCase(str)) {
                            Toast.makeText(An_Huan_HomeActivity.this, "安检项目开始成功", Toast.LENGTH_LONG)
                                    .show();
                            //不合格项目--外检项目--默认提交数据
                            if (an_huan_WaiJianAddRecordModelList != null && an_huan_WaiJianAddRecordModelList.size() > 0) {
                                UtilsLog.e("an_huan_WaiJianAddRecordModelList-result==!!!!!!==null");
                                uploadDataByWaiJianItem();
                            } else {
                                UtilsLog.e("an_huan_WaiJianAddRecordModelList-result=====null");
                            }
                        } else {
                            Toast.makeText(An_Huan_HomeActivity.this, "安检项目开始失败，请重试", Toast.LENGTH_LONG)
                                    .show();
                        }
//                            updateCarStatusInfor_anjian(1);
//                        getDataReportData();
//                        Intent intent = new Intent(instances, WaiJianPhotoActivity.class);
//                        intent.putExtra("CarDetailsActivity_CarsInforModel", carsInforModel);
//                        intent.putExtra("CarDetailsActivity_acCarDetailsWaijianchedao",
//                                includeAnWaijianchedao.getText().toString().trim());
//                        intent.putExtra("CarDetailsActivity_Line", Line);
//                        intent.putExtra("login_w_name", Login_name);
//                        intent.putExtra("login_IDNumber", login_IDNumber);
//
//                        startActivity(intent);
//                        finish();
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        String logStr2 = "\n" + "外检项目开始请求--onError" + "\n" +
                                "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                        UtilsLog.e("getDataWaiJainStart-onError==" + response.body());
                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                    }
                });
    }

    //获取需要检测的人工检验项目接口
    private void getMyCarItems() {
        ItemsModel model = new ItemsModel();
        model.setCarType(carsInforModel.getType());
        model.setDetectCategroy(carsInforModel.getDetectionCategory());
        model.setPassengerNb(carsInforModel.getApprovedLoad());
        model.setPlateType(carsInforModel.getPlateType());
        model.setVehicleID(String.valueOf(carsInforModel.getVehicleID()));
        String registerTime = carsInforModel.getRegisteDate();
        String str = registerTime.substring(6, registerTime.length() - 2).trim();
        String registerdate = DateUtil.getDateTimeFromMillisecond(Long.parseLong(str));
        model.setRegisteDate(registerdate);

        Gson gson = new Gson();
        String json_str = gson.toJson(model);
        UtilsLog.e("getMyCarItems--获取需要检测的人工检验项目接口-json_str==" + json_str);
        UtilsLog.e("getMyCarItems--获取需要检测的人工检验项目接口-url==" +
                SharedPreferencesUtils.getIP(this) + GET_MY_ITEM_38900);
        String logStr = "\n" + "外检--获取需要检测的人工检验项目接口--请求" +
                "\n" + "URL::" + SharedPreferencesUtils.getIP(this) +
                GET_MY_ITEM_38900 + "\n" + "JSON::" + json_str + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + GET_MY_ITEM_38900).tag(this)
                .upJson(json_str)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(An_Huan_HomeActivity.this, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("getMyCarItems-获取需要检测的人工检验项目接口newResult==" + newResult);
                        String logStrf = "\n" + "外检--获取需要检测的人工检验项目接口--请求成功" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());

                        if (!TextUtils.isEmpty(newResult) && !"[[]]".equals(newResult) && !"[{}]".equals
                                (newResult) && !"[]".equals(result)) {
                            List<CheckItemModel> DiPanDongTai_checkItemlList = new ArrayList<>();
                            mycar_checkItemlList = new ArrayList<CheckItemModel>();
                            DiPanDongTai_checkItemlList = JsonUtil.stringToArray(newResult,
                                    CheckItemModel[].class);
                            if (DiPanDongTai_checkItemlList != null && DiPanDongTai_checkItemlList.size() > 0) {
                                reportedJsonStr4(DiPanDongTai_checkItemlList);
                                List<Item_2Model> Item_2Model_list = new ArrayList<>();//Code2去重后的所有数据
                                Item_2Model item_2 = null;
                                for (int i = 0; i < DiPanDongTai_checkItemlList.size(); i++) {
                                    mycar_checkItemlList.add(DiPanDongTai_checkItemlList.get(i));
                                    if (DiPanDongTai_checkItemlList.get(i).getFlag().equals("2")) {
                                        UtilsLog.e("flag=====" + i + "======" + DiPanDongTai_checkItemlList.get(i).getFlag() + "\n" +
                                                DiPanDongTai_checkItemlList.get(i).toString());
                                        is_hege = true;
                                        UtilsLog.e("55555555555555555555555===is_hege==" + is_hege);
                                    }
                                    if (DiPanDongTai_checkItemlList.get(i).getCode1().equals("1") ||
                                            DiPanDongTai_checkItemlList.get(i).getCode1().equals("2") ||
                                            DiPanDongTai_checkItemlList.get(i).getCode1().equals("3") ||
                                            DiPanDongTai_checkItemlList.get(i).getCode1().equals("4") ||
                                            DiPanDongTai_checkItemlList.get(i).getCode1().equals("5")
                                            ||
                                            DiPanDongTai_checkItemlList.get(i).getCode1().equals("6")
                                            ||
                                            DiPanDongTai_checkItemlList.get(i).getCode1().equals("7")) {
                                        item_2 = new Item_2Model();
                                        item_2.setID(DiPanDongTai_checkItemlList.get(i).getID());
                                        item_2.setCode1(DiPanDongTai_checkItemlList.get(i).getCode1());
                                        item_2.setCode2(DiPanDongTai_checkItemlList.get(i).getCode2());
                                        item_2.setName2(DiPanDongTai_checkItemlList.get(i).getName2());
                                        item_2.setFlag(DiPanDongTai_checkItemlList.get(i).getFlag());
                                        Item_2Model_list.add(item_2);

                                    }
                                }
                                for (int k = 0; k < Item_2Model_list.size() - 1; k++) {
                                    for (int j = Item_2Model_list.size() - 1; j > k; j--) {
                                        if (Item_2Model_list.get(j).getCode2().equals(Item_2Model_list.get(k)
                                                .getCode2())) {
                                            Item_2Model_list.remove(j);
                                        }
                                    }
                                }
                                //f1_record--不合格项目--初始化默认数据
                                initData2();
                                setDataModel();

                                if (myChoiceModelList != null && myChoiceModelList.size() > 0) {
                                    for (int i = 0; i < myChoiceModelList.size(); i++) {
//                                        UtilsLog.e("An_HUan_HomeActivity==myChoiceModelList==111111=" + myChoiceModelList.get(i).toString());
                                        String Code2 = myChoiceModelList.get(i).getCode2().toString().trim();
                                        for (int j = 0; j < Item_2Model_list.size(); j++) {
//                                            UtilsLog.e("An_HUan_HomeActivity==an_huan_Item_2Model_list==22222=" + an_huan_Item_2Model_list.get(j).toString());
                                            String code2_my = Item_2Model_list.get(j).getCode2().toString()
                                                    .trim();
                                            if (Code2.equals(code2_my)) {
                                                myChoiceModelList.get(i).setCode_values(Item_2Model_list.get(j).getFlag());
//                                            myChoiceModelList.get(i).setCode_values("1");
                                            }
                                        }
                                    }
                                } else {
                                    UtilsLog.e("myChoiceModelList=================");
                                }

                                if (myChoiceModelList_waijian != null && myChoiceModelList_waijian.size() > 0) {
                                    for (int i = 0; i < myChoiceModelList_waijian.size(); i++) {
//                                        UtilsLog.e("myChoiceModelList_waijian==6666=" + myChoiceModelList_waijian.get(i).toString());
                                        String Code2 = myChoiceModelList_waijian.get(i).getCode2().toString().trim();
                                        for (int j = 0; j < Item_2Model_list.size(); j++) {
//                                            UtilsLog.e("myChoiceModelList_waijian==an_huan_Item_2Model_list===7777==" + an_huan_Item_2Model_list.get(j).toString());
                                            String code2_my = Item_2Model_list.get(j).getCode2().toString()
                                                    .trim();
                                            if (Code2.equals(code2_my)) {
                                                myChoiceModelList_waijian.get(i).setCode_values(Item_2Model_list.get(j).getFlag());
                                            }
                                        }
                                    }
//                                    for (int i = 0; i < an_huan_Item_2Model_list.size(); i++) {
//                                        UtilsLog.e("myChoiceModelList_waijian==an_huan_Item_2Model_list=" + an_huan_Item_2Model_list.get(i).toString());
//                                    }
                                    upload_code_str = "";
                                    for (int i = 0; i < myChoiceModelList_waijian.size(); i++) {
//                                        UtilsLog.e("myChoiceModelList_waijian==upload_code_str=" + myChoiceModelList_waijian.get(i).toString());
                                        upload_code_str = upload_code_str + "\"" + myChoiceModelList_waijian.get(i).getCode_key() + "\""
                                                + ":" + "\"" + myChoiceModelList_waijian.get(i).getCode_values() + "\"" + ",";
                                    }

//                                    for (int i = 0; i < code2_list_wenzhou.size(); i++) {
//                                        UtilsLog.e("code2_list_wenzhou==upload_code_str=" + code2_list_wenzhou.get(i).toString());
//                                        upload_code_str = upload_code_str + "\"" + code2_list_wenzhou.get(i).getCode_key() + "\""
//                                                + ":" + "\"" + code2_list_wenzhou.get(i).getCode_values() + "\"" + ",";
//                                    }

                                    if (upload_code_str.length() > 0) {
                                        upload_code_str = upload_code_str.substring(0, upload_code_str.length() - 1);
                                    }
                                    UtilsLog.e("upload_code_str========" + upload_code_str);

                                    String logStrfw = "\n" + "外检-111111111-获取需要检测的人工检验项目接口--upload_code_str" +
                                            "\n" + "upload_code_str::" + upload_code_str;
                                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                                } else {
                                    UtilsLog.e("myChoiceModelList_waijian=================");
                                    String logStrfw = "\n" + "外检-22222-获取需要检测的人工检验项目接口--upload_code_str" +
                                            "\n" + "myChoiceModelList_waijian=================";
                                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                                }

                                if (is_hege && is_first) {
                                    UtilsLog.e("6666666666666666666666666666666=");
                                    MessageDialog.show(An_Huan_HomeActivity.this, "提示", "有不合格项目(安检项目)", "知道了", null);
                                    is_first = false;
                                    String logStrfw = "\n" + "外检-3333333-获取需要检测的人工检验项目接口--upload_code_str" +
                                            "\n" + "6666666666666666666666666666666=================";
                                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                                } else {
                                    UtilsLog.e("777777777777777777777777777777=");
                                    String logStrfw = "\n" + "外检-44444444-获取需要检测的人工检验项目接口--upload_code_str" +
                                            "\n" + "777777777777777777777777777777=================";
                                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                                }
                            } else {
                                String logStrfw = "\n" + "外检-55555555-获取需要检测的人工检验项目接口--upload_code_str" +
                                        "\n" + "getMyCarItems-Result==没有获取到当前车辆检测到的项目=================";
                                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                                UtilsLog.e("getMyCarItems-Result==没有获取到当前车辆检测到的项目");
                            }

                        } else {
                            String logStrfw = "\n" + "外检-66666666-获取需要检测的人工检验项目接口--upload_code_str" +
                                    "\n" + "getGET_ALL_ITEMList-result==" + "没有数据==========";
                            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                            UtilsLog.e("getGET_ALL_ITEMList-result==" + "没有数据");
                        }
//                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("getMyCarItems-onError==" + response.body());
//                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                        String logStrf = "\n" + "外检--获取需要检测的人工检验项目接口--请求失败--error" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());
                        MessageDialog.show(An_Huan_HomeActivity.this, "提示", "安检项目请求失败", "知道了", null);
                    }
                });
    }


    //外检检测结束
    String getDataWaiJainEnd_upjson_url;

    private void getDataWaiJainEnd(String endTime) {
        UtilsLog.e("安检---项目结束=======");
        String id = "", times = "";
        if (Is_An_Huan == 1) {
            times = huanBaoModel.getTimes();
            id = String.valueOf(huanBaoModel.getID());
        } else {
            times = carsInforModel.getTimes();
            id = String.valueOf(carsInforModel.getID());
        }

        CarItemEndModel carItemStartModel = new CarItemEndModel();
        // 0:安检  1：环保  2:两者都有
        if (Is_An_Huan == 1) {
            carItemStartModel.setPlatformSN(huanBaoModel.getPlatformSN());
            carItemStartModel.setPlateType(huanBaoModel.getPlateType());
//        carItemStartModel.setPlateNO(carsInforModel.getPlateNO());
//            carItemStartModel.setPlateNO(huanBaoModel.getPlateRegion() +
//                    huanBaoModel.getPlateNO()
//                    + huanBaoModel.getPlateExtra());

//            if (SharedPreferencesUtils.getAddress(An_Huan_HomeActivity.this).equals("温州")) {
//                carItemStartModel.setPlateNO(huanBaoModel.getPlateRegion()
//                        + huanBaoModel.getPlateNO()
//                        + huanBaoModel.getPlateExtra());
//            } else if (SharedPreferencesUtils.getAddress(An_Huan_HomeActivity.this).equals("常山")) {
            carItemStartModel.setPlateNO(huanBaoModel.getPlateRegion()
                    + huanBaoModel.getPlateNO());
//            }
            carItemStartModel.setDetection_ID(String.valueOf(huanBaoModel.getID()));
            carItemStartModel.setVIN(huanBaoModel.getVIN());
            carItemStartModel.setTest_times(huanBaoModel.getTimes());
            carItemStartModel.setLine(includeHuanJiancexianBianhao.getText().toString().trim());
        } else {
            carItemStartModel.setLine(includeAnWaijianchedao.getText().toString().trim());
            carItemStartModel.setPlatformSN(carsInforModel.getPlatformSN());
            carItemStartModel.setPlateType(carsInforModel.getPlateType());
//        carItemStartModel.setPlateNO(carsInforModel.getPlateNO());
//            carItemStartModel.setPlateNO(carsInforModel.getPlateRegion() +
//                    carsInforModel.getPlateNO()
//                    + carsInforModel.getPlateExtra());
//            if (SharedPreferencesUtils.getAddress(An_Huan_HomeActivity.this).equals("温州")) {
//                carItemStartModel.setPlateNO(carsInforModel.getPlateRegion()
//                        + carsInforModel.getPlateNO()
//                        + carsInforModel.getPlateExtra());
//            } else if (SharedPreferencesUtils.getAddress(An_Huan_HomeActivity.this).equals("常山")) {
            carItemStartModel.setPlateNO(carsInforModel.getPlateRegion()
                    + carsInforModel.getPlateNO());
//            }
            carItemStartModel.setDetection_ID(String.valueOf(carsInforModel.getID()));
            carItemStartModel.setVIN(carsInforModel.getVIN());
            carItemStartModel.setTest_times(carsInforModel.getTimes());
        }

        carItemStartModel.setDetectionDevID("");
        carItemStartModel.setItemCode(Item_Code);
//        BaseApplication.W_ItemEnd_time = "";
//        BaseApplication.W_ItemEnd_time = DateUtil.currentTime2();
        my_item_end_time = BaseApplication.W_ItemEnd_time;
        carItemStartModel.setDetectionItemEndDate(BaseApplication.W_ItemEnd_time);
//        carItemStartModel.setDetectionItemEndDate(endTime);
        Gson gson = new Gson();
        String jsonStr = gson.toJson(carItemStartModel);
//        String upjson_url = "{[" + jsonStr.substring(1, jsonStr.length() - 1) + "]}";
        getDataWaiJainEnd_upjson_url = "{" + jsonStr.substring(1, jsonStr.length() - 1) + "}";
        UtilsLog.e("getDataWaiJainEnd---jsonStr==" + getDataWaiJainEnd_upjson_url);
        UtilsLog.e("getDataWaiJainEnd---url==" + SharedPreferencesUtils.getIP(this) + ITEM_END);
        String logStr = "\n" + "外检项目结束--json" + "\n" +
                "JSON::" + getDataWaiJainEnd_upjson_url + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + ITEM_END).tag(this)
                .upJson(getDataWaiJainEnd_upjson_url)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        // 0:安检  1：环保  2:两者都有
                        String result = response.body();
                        UtilsLog.e("getDataWaiJainEnd-result==" + result);
//                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("getDataWaiJainEnd-newResult==" + newResult);
                        String logStr = "\n" + "外检项目结束--请求成功" + "\n" +
                                "JSON::" + getDataWaiJainEnd_upjson_url +
                                "\n" + "result::" + result;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        if ("ok".equalsIgnoreCase(newResult)) {
//                            Toast.makeText(An_Huan_HomeActivity.this, "安检外检项目完成", Toast
//                                    .LENGTH_LONG).show();
                            getDataReportData();
//                            Handler handler = new Handler();
//                            handler.postDelayed(new Runnable() {
//                                @Override
//                                public void run() {
//                                    getDataReportData2();
//                                }
//                            }, 500);//后执行Runnable中的run方法
                            //新国标升级上传本地后台数据
                            Handler handler = new Handler();
                            handler.postDelayed(new Runnable() {
                                @Override
                                public void run() {
                                    initJsonDataToPlateform(BaseApplication.W_ItemEnd_time);
                                }
                            }, 300);//后执行Runnable中的run方法


                            updateCarStatusInfor_anjian(1);
//                            EndAllItem(id);
                            Handler handler22 = new Handler();
                            handler22.postDelayed(new Runnable() {
                                @Override
                                public void run() {
                                    //项目总结束
                                    EndAllItem(String.valueOf(carsInforModel.getID()));
                                }
                            }, 1100);//后执行Runnable中的run方法
                        } else {
                            MessageDialog.show(An_Huan_HomeActivity.this, "提示", "外检平台下线失败，请尝试重新下线");
//                            showDialog("外检平台下线失败，请尝试重新下线");
//                            showDialog("车辆下线失败，请重试，如果还未成功请联系管理员");
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("getDataWaiJainEnd-onError==" + response.body());
                        String logStr = "\n" + "外检项目结束-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
                                ITEM_END + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                        MessageDialog.show(An_Huan_HomeActivity.this, "提示", "车辆下线失败，请重试，如果还未成功请联系管理员");
//                        showDialog("车辆下线失败，请重试，如果还未成功请联系管理员");
                    }
                });
    }

    //外检上传平台数据
    String upjson_url;

    private void uploadPlatformData_w(WaiJainDataModel waiJainDataModel, int f) {
        String logStr34 = "\n" + "uploadPlatformData_w----code2数据----" + "\n" + "is_500::" + is_500 + "\n"
                + "Is_An_Huan::" + Is_An_Huan + "\n"
                + "upload_code_str_500::" + upload_code_str_500 + "\n"
                + "upload_code_str::" + upload_code_str + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr34.getBytes());
        Gson gson = new Gson();
        String jsonStr = gson.toJson(waiJainDataModel);
        if (Is_An_Huan == 0 || Is_An_Huan == 2) {
//            if (SharedPreferencesUtils.getCode2List(this)) {
            String logStr = "\n" + "外检上传平台数据--uploadPlatformData_w----upload_code_str_500" + "\n";
            if (is_500) {
                upload_code_str_500 = TextUtils.isEmpty(upload_code_str_500) ? "" : "," + upload_code_str_500;
                upjson_url = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + upload_code_str_500 + "," + dbModelData(false, true) + "}]";
                logStr += "is_500==true" + "\n" + "upload_code_str_500==" + upload_code_str_500 +
                        "\n" + "upjson_url==" + upjson_url + "\n" + "Is_An_Huan==" + "\n";
            } else {
                upload_code_str = TextUtils.isEmpty(upload_code_str) ? "" : "," + upload_code_str;
                upjson_url = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + upload_code_str + "," + dbModelData(false, true) + "}]";
                logStr += "is_500==false" + "\n" + "upload_code_str==" + upload_code_str +
                        "\n" + "upjson_url==" + upjson_url + "\n" + "Is_An_Huan==" + "\n";
            }
            UtilsLog.e(logStr);
            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//            } else {
//                upjson_url = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "," + appendCode2AndValues
//                        () + "," + dbModelData(false, true) + "}]";
//                String logStr = "\n" + "外检上传平台数据--uploadPlatformData_w--getCode2List--upjson_url" + "\n" +
//                        PLAT_FORM_DATA + "\n" + "JSON::" + upjson_url + "\n";
//                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//            }
        } else {
            upload_code_str = TextUtils.isEmpty(upload_code_str) ? "" : "," + upload_code_str;
            upjson_url = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + upload_code_str + "}]";
            String logStr = "\n" + "外检上传平台数据--uploadPlatformData_w--Is_An_Huan == 1--upjson_url" + "\n" +
                    PLAT_FORM_DATA + "\n" + "JSON::" + upjson_url + "\n" + "Is_An_Huan==" + "\n";
            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
            UtilsLog.e(logStr);
        }
//        UtilsLog.e("uploadPlatformData_w-upload_code_str==" + upload_code_str);
        String logStr = "\n" + "外检上传平台数据--uploadPlatformData_w----json" + "\n" + "URL::" +
                SharedPreferencesUtils.getIP(this) + "" +
                PLAT_FORM_DATA + "\n" + "JSON::" + upjson_url + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("uploadPlatformData_w---jsonStr==" + upjson_url);
        UtilsLog.e("uploadPlatformData_w---url==" + SharedPreferencesUtils.getIP(this) + PLAT_FORM_DATA);
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + PLAT_FORM_DATA).tag(this)
                .upJson(upjson_url)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("uploadPlatformData_w-result==" + result);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("uploadPlatformData_w-newResult==" + newResult);
                        String logStr = "\n" + "外检上传平台数据--请求成功" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
                                PLAT_FORM_DATA + "\n" + "JSON::" + upjson_url +
                                "\n" + "result::" + result;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        if ("ok".equalsIgnoreCase(newResult)) {
                            if (f == 0) {
                                //发安检结束
                                Handler handler = new Handler();
                                handler.postDelayed(new Runnable() {
                                    @Override
                                    public void run() {
                                        getDataWaiJainEnd("");
                                    }
                                }, 400);//后执行Runnable中的run方法
                            } else {
                                //发环保结束
                                getDataHuanBaoEnd();
//                                finish();
                            }
                        } else {
                            acAnHuanBtnXiangmuJieshu.setEnabled(true);
//                            CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                            Intent i = new Intent(An_Huan_HomeActivity.this, ErrorMsgActivity.class);
                            i.putExtra("error_msg", result);
                            startActivity(i);

//                            if (f == 0) {
//                                //安检
//                                CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
//                                Intent i = new Intent(An_Huan_HomeActivity.this, ErrorMsgActivity.class);
//                                i.putExtra("error_msg", result);
//                                startActivity(i);
//                            }else{
//                                //环保
//                                getDataHuanBaoEnd();
//                            }
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("uploadPlatformData_w-onError==" + response.body());
                        String logStr = "\n" + "外检上传平台数据-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
                                PLAT_FORM_DATA + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                        MessageDialog.show(An_Huan_HomeActivity.this, "提示", "上传平台数据失败，请重试，如果还未成功请联系管理员");
//                        showDialog("上传平台数据失败，请重试，如果还未成功请联系管理员");
                        acAnHuanBtnXiangmuJieshu.setEnabled(true);
                    }
                });
    }

    //组装要上报的json
    private String reportedJsonStr3() {
        // 0:安检  1：环保  2:两者都有
        String id = "", times = "";
        if (Is_An_Huan == 1) {
            times = huanBaoModel.getTimes();
            id = String.valueOf(huanBaoModel.getID());
        } else {
            times = carsInforModel.getTimes();
            id = String.valueOf(carsInforModel.getID());
        }

        String myjson = "";
        CodeListModel codeListModel = null;
        List<CodeListModel> codeList_list = new ArrayList<>();
        if (BaseApplication.BaseApplication_buHeGeModel3List != null
                && BaseApplication.BaseApplication_buHeGeModel3List.size() > 0) {
            UtilsLog.e("BaseApplication_buHeGeModel3List=传过来的数据=" +
                    BaseApplication.BaseApplication_buHeGeModel3List.toString());
            String logStr = "\n" + "外检上传平台数据-BaseApplication.BaseApplication_buHeGeModel3List---" +
                    "\n" + "BaseApplication.BaseApplication_buHeGeModel3List::" + BaseApplication.BaseApplication_buHeGeModel3List.toString() + "\n";
            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
            //去重
            Utils.removeDuplicate(BaseApplication.BaseApplication_buHeGeModel3List);
            if (BaseApplication.BaseApplication_buHeGeModel3List != null
                    && BaseApplication.BaseApplication_buHeGeModel3List.size() > 0) {
                for (int i = 0; i < BaseApplication.BaseApplication_buHeGeModel3List.size(); i++) {
                    UtilsLog.e("BaseApplication_buHeGeModel3List=去掉IsCheck==1后的数据=" +
                            BaseApplication.BaseApplication_buHeGeModel3List.get(i).toString());
                    if ("1".equals(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getIsCheck())) {
                        codeListModel = new CodeListModel();
                        codeListModel.setDataType(Item_Code);
                        codeListModel.setDetection_ID(id);
                        codeListModel.setTest_times(times);
                        codeListModel.setUnqualified_Code1(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getCode1());
                        codeListModel.setUnqualified_Code2(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getCode2());
                        codeListModel.setUnqualified_Code3(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getCode3());
                        codeList_list.add(codeListModel);
                    }
                }
                if (codeList_list.size() > 0 && codeList_list != null) {
                    for (int i = 0; i < codeList_list.size(); i++) {
                        UtilsLog.e("不合格项目--codeList_list===" + codeList_list.get(i).toString());
                    }
                }
                Gson gson = new Gson();
                String jsonStr = gson.toJson(codeList_list);
//            myjson = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "}]";
                myjson = jsonStr;
                UtilsLog.e("reportedJsonStr3333==" + myjson);
            } else {
                codeListModel = new CodeListModel();
                codeListModel.setDataType(Item_Code);
                codeListModel.setDetection_ID(id);
                codeListModel.setTest_times(times);
                codeListModel.setUnqualified_Code1("0");
                codeListModel.setUnqualified_Code2("0");
                codeListModel.setUnqualified_Code3("0");
                codeList_list.add(codeListModel);
                Gson gson = new Gson();
                String jsonStr = gson.toJson(codeList_list);
//            myjson = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "}]";
                myjson = jsonStr;
                UtilsLog.e("reportedJsonStr4444==" + myjson);
            }
        } else {
            if (list2 != null && !list2.isEmpty()) {
                myjson = reportedJsonStr4_2(list2);
            } else {
                String logStr = "\n" + "外检上传平台数据-BaseApplication.BaseApplication_buHeGeModel3List---" +
                        "\n" + "BaseApplication.BaseApplication_buHeGeModel3List::-----null-----" + "\n";
                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                codeListModel = new CodeListModel();
                codeListModel.setDataType(Item_Code);
                codeListModel.setDetection_ID(id);
                codeListModel.setTest_times(times);
                codeListModel.setUnqualified_Code1("0");
                codeListModel.setUnqualified_Code2("0");
                codeListModel.setUnqualified_Code3("0");
                codeList_list.add(codeListModel);
                Gson gson = new Gson();
                String jsonStr = gson.toJson(codeList_list);
//            myjson = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "}]";
                myjson = jsonStr;
                UtilsLog.e("reportedJsonStr555==" + myjson);
            }

        }
        return myjson;
    }

    private String reportedJsonStr4_json = "";

    private String reportedJsonStr4(List<CheckItemModel> data_list) {
        // 0:安检  1：环保  2:两者都有
        String id = "", times = "";
        if (Is_An_Huan == 1) {
            times = huanBaoModel.getTimes();
            id = String.valueOf(huanBaoModel.getID());
        } else {
            times = carsInforModel.getTimes();
            id = String.valueOf(carsInforModel.getID());
        }

        String myjson = "";
        CodeListModel codeListModel = null;
        List<CodeListModel> codeList_list = new ArrayList<>();
        for (int i = 0; i < data_list.size(); i++) {
            if (data_list.get(i).getCode1().equals("1") ||
                    data_list.get(i).getCode1().equals("2") ||
                    data_list.get(i).getCode1().equals("3") ||
                    data_list.get(i).getCode1().equals("4") ||
                    data_list.get(i).getCode1().equals("5") ||
                    data_list.get(i).getCode1().equals("6") ||
                    data_list.get(i).getCode1().equals("7")) {
                String va = data_list.get(i).getFlag();
                if ("2".equals(va)) {
                    codeListModel = new CodeListModel();
                    codeListModel.setDataType(Item_Code);
                    codeListModel.setDetection_ID(id);
                    codeListModel.setTest_times(times);
                    codeListModel.setUnqualified_Code1(data_list.get(i).getCode1());
                    codeListModel.setUnqualified_Code2(data_list.get(i).getCode2());
                    codeListModel.setUnqualified_Code3(data_list.get(i).getCode3());
                    codeList_list.add(codeListModel);
                }
            }
        }

        Gson gson = new Gson();
        if (codeList_list.size() > 0 && codeList_list != null) {
            myjson = gson.toJson(codeList_list);
        } else {
            codeListModel = new CodeListModel();
            codeListModel.setDataType(Item_Code);
            codeListModel.setDetection_ID(id);
            codeListModel.setTest_times(times);
            codeListModel.setUnqualified_Code1("0");
            codeListModel.setUnqualified_Code2("0");
            codeListModel.setUnqualified_Code3("0");
            codeList_list.add(codeListModel);
            myjson = gson.toJson(codeList_list);
        }
        reportedJsonStr4_json = myjson;
        UtilsLog.e("reportedJsonStr4444==" + myjson);
        String logStr = "\n" + "----reportedJsonStr4-----" + "\n" + myjson + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        return myjson;
    }

    private String reportedJsonStr4_2(List<CheckItemModel> data_list) {
        // 0:安检  1：环保  2:两者都有
        String id = "", times = "";
        if (Is_An_Huan == 1) {
            times = huanBaoModel.getTimes();
            id = String.valueOf(huanBaoModel.getID());
        } else {
            times = carsInforModel.getTimes();
            id = String.valueOf(carsInforModel.getID());
        }

        String myjson_reportedJsonStr4_2 = "";
        CodeListModel codeListModel = null;
        List<CodeListModel> codeList_list = new ArrayList<>();
        for (int i = 0; i < data_list.size(); i++) {
            if (data_list.get(i).getCode1().equals("1") ||
                    data_list.get(i).getCode1().equals("2") ||
                    data_list.get(i).getCode1().equals("3") ||
                    data_list.get(i).getCode1().equals("4") ||
                    data_list.get(i).getCode1().equals("5") ||
                    data_list.get(i).getCode1().equals("6") ||
                    data_list.get(i).getCode1().equals("7")) {
                String va = data_list.get(i).getFlag();
                if ("2".equals(va)) {
                    codeListModel = new CodeListModel();
                    codeListModel.setDataType(Item_Code);
                    codeListModel.setDetection_ID(id);
                    codeListModel.setTest_times(times);
                    codeListModel.setUnqualified_Code1(data_list.get(i).getCode1());
                    codeListModel.setUnqualified_Code2(data_list.get(i).getCode2());
                    codeListModel.setUnqualified_Code3(data_list.get(i).getCode3());
                    codeList_list.add(codeListModel);
                }
            }
        }

        Gson gson = new Gson();
        if (codeList_list.size() > 0 && codeList_list != null) {
            myjson_reportedJsonStr4_2 = gson.toJson(codeList_list);
        } else {
            codeListModel = new CodeListModel();
            codeListModel.setDataType(Item_Code);
            codeListModel.setDetection_ID(id);
            codeListModel.setTest_times(times);
            codeListModel.setUnqualified_Code1("0");
            codeListModel.setUnqualified_Code2("0");
            codeListModel.setUnqualified_Code3("0");
            codeList_list.add(codeListModel);
            myjson_reportedJsonStr4_2 = gson.toJson(codeList_list);
        }
//        reportedJsonStr4_json = myjson;
        UtilsLog.e("reportedJsonStr4_2==" + myjson_reportedJsonStr4_2);
        String logStr = "\n" + "----reportedJsonStr4_2-----" + "\n" + myjson_reportedJsonStr4_2 + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        return myjson_reportedJsonStr4_2;
    }

    String myjson2;

    private void getDataReportData() {
        UtilsLog.e("getDataReportData---url==" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) + REPORTED_DATA);
        if (is_500) {
            myjson2 = reportedJsonStr3();
        } else {
            myjson2 = reportedJsonStr4_json;
        }
        UtilsLog.e("getDataReportData-result=myjson=" + myjson2);
        String logStr = "\n" + "外检上传自己后台数据--getDataReportData---" +
                "\n" + "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
                REPORTED_DATA + "\n" + "JSON::" + myjson2 + "\n" + "is_500::" + is_500;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) + REPORTED_DATA).tag(An_Huan_HomeActivity.this)
                .upJson(myjson2)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("getDataReportData-result==" + result);
                        String logStr = "\n" + "外检上传自己后台数据--请求成功" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
                                REPORTED_DATA + "\n" + "JSON::" + myjson2 +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                        if ("\"ok\"".equals(result)) {
//                            Toast.makeText(instances, "上报数据成功", Toast.LENGTH_LONG).show();
//                            instances.finish();
                        } else {
                            if (gotoTakePhotoCounts < 5) {
                                String logStr2 = "\n" + "外检上传自己后台次数=循环=" +
                                        "\n" + "第" + gotoTakePhotoCounts + "次" + "\n" + "JSON::" +
                                        myjson2 + "\n" + "result::" + result;
                                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                                getDataReportData();
                                gotoTakePhotoCounts++;
                            } else {
                                CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                                String logStr2 = "\n" + "外检上传自己后台次数=循环5次请求失败--没治了=" +
                                        "\n" + "JSON::" + myjson2 + "\n" +
                                        "result::" + result;
                                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                                MessageDialog.show(An_Huan_HomeActivity.this, "提示", "上传后台数据失败，请重试，如果还未成功请联系管理员");
//                                showDialog("上传后台数据失败，请重试，如果还未成功请联系管理员");
                            }
//                            showDialog("上传后台数据失败，请重试，如果还未成功请联系管理员");
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("getDataReportData-onError==" + response.body());
                        UtilsLog.e("getDataReportData-onError==" + response.getException());
                        String logStr = "\n" + "外检上传自己后台数据-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
                                REPORTED_DATA + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
//                        Toast.makeText(instances, getResources().getString(R.string.services_error), Toast
//                                .LENGTH_LONG).show();
                        MessageDialog.show(An_Huan_HomeActivity.this, "提示", "上传后台数据失败，请重试，如果还未成功请联系管理员");
//                        showDialog("上传后台数据失败，请重试，如果还未成功请联系管理员");
                    }
                });
    }


    private void getDataReportData33(WaiJainDataModel waiJainDataModel) {
        UtilsLog.e("getDataReportData33---url==" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) + REPORTED_DATA);
//        myjson = reportedJsonStr3();
        Gson gson = new Gson();
        String jsonStr = "[" + gson.toJson(waiJainDataModel) + "]";
        UtilsLog.e("getDataReportData33-=json=" + jsonStr);
        String logStr = "\n" + "getDataReportData33--上传本地后台数据---json" + "\n" +
                "json::" + jsonStr + "\n" +
                "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) + REPORTED_DATA;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) + REPORTED_DATA).tag(An_Huan_HomeActivity.this)
                .upJson(jsonStr)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("getDataReportData33-result==" + result);
                        String logStr = "\n" + "getDataReportData33--请求成功" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
                                REPORTED_DATA + "\n" + "JSON::" + jsonStr +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                        if ("\"ok\"".equals(result)) {
//                            Toast.makeText(instances, "上报数据成功", Toast.LENGTH_LONG).show();
//                            instances.finish();
                        } else {
//                            Intent i = new Intent(An_Huan_HomeActivity.this, ErrorMsgActivity.class);
//                            i.putExtra("error_msg", result);
//                            startActivity(i);
//                            showDialog("上传后台数据失败，请重试，如果还未成功请联系管理员");
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("getDataReportData33-onError==" + response.body());
                        UtilsLog.e("getDataReportData33-onError==" + response.getException());
                        String logStr = "\n" + "getDataReportData33-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
                                REPORTED_DATA + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
//                        Toast.makeText(instances, getResources().getString(R.string.services_error), Toast
//                                .LENGTH_LONG).show();
                        MessageDialog.show(An_Huan_HomeActivity.this, "提示", "上传后台数据失败，请重试，如果还未成功请联系管理员");
//                        showDialog("上传后台数据失败，请重试，如果还未成功请联系管理员");
                    }
                });
    }


    //视频接口
    private void uploadVideo(VideoModel model) {

//        BaseApplication.W_ItemStart_time = DateUtil.currentTime2();
        Gson gson = new Gson();
        String jsonStr = gson.toJson(model);
        UtilsLog.e("uploadVideo---jsonStr==" + jsonStr);
        UtilsLog.e("uploadVideo---url==" + SharedPreferencesUtils.getIP(this) + VIDEO_ITEM);
//        String logStr = "\n" + "外检--uploadVideo--请求" +
//                "\n" + "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
//                VIDEO_ITEM + "\n" + "JSON::" + jsonStr + "\n";
//        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + VIDEO_ITEM).tag(this)
                .upJson(jsonStr)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("uploadVideo-result==" + result);
//                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
//                        String logStrf = "\n" + "外检--uploadVideo--请求成功" +
//                                "\n" + "result::" + response.body();
//                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("uploadPlatformData_w-onError==" + response.body());
//                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                        String logStr = "\n" + "外检--uploadVideo-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
                                VIDEO_ITEM + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                    }
                });
    }

    /**
     * 项目总结束接口,最后一个执行
     */
    private void EndAllItem(final String detectionID) {
        UtilsLog.e("项目总结束接口=======");
        UtilsLog.e("EndAllItem---url==" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) + ITEM_ALL_END +
                detectionID + "/DetectionID");
        OkGo.<String>get(SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) + ITEM_ALL_END +
                detectionID + "/DetectionID").tag(An_Huan_HomeActivity.this)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        //完成按钮可点击
//                        acWaijianBtnWancheng2.setEnabled(true);

                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                        String result = response.body();
                        UtilsLog.e("EndAllItem-result==" + result);
                        String logStr = "\n" + "外检项目总结束:总结束:总结束--请求成功" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
                                ITEM_ALL_END + detectionID + "/DetectionID" +
                                "\n" + "result::" + result;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        Toast.makeText(An_Huan_HomeActivity.this, "外检项目完成", Toast
                                .LENGTH_LONG).show();
                        finish();

//                        if ("\"ok\"".equals(result)) {
//
//                            updateCarStatusInfor_anjian(1);
//                            Toast.makeText(instances, "外检项目完成", Toast
//                                    .LENGTH_LONG).show();
//
//                        } else {
//                            showDialog("车辆下线失败，请重试，如果还未成功请联系管理员");
//                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        String logStr = "\n" + "外检项目总结束:总结束:总结束-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
                                ITEM_ALL_END + detectionID + "/DetectionID" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        UtilsLog.e("EndAllItem-onError==" + response.body());
                        UtilsLog.e("EndAllItem-onError==" + response.getException());
                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                        MessageDialog.show(An_Huan_HomeActivity.this, "提示", "车辆下线失败，请重试，如果还未成功请联系管理员");
//                        showDialog("车辆下线失败，请重试，如果还未成功请联系管理员");
                    }
                });
    }

    /**
     * 更新车辆状态
     *
     * @param flag flag:0 未检测
     * flag:1 项目开始
     * flag:2 项目结束
     * flag:917  中途退出的情况
     */
    String jsonStr22;

    public void updateCarStatusInfor_anjian(int flag) {
        UtilsLog.e("更新车辆状态=======安检====");
        // 0:安检  1：环保  2:两者都有
        String id = "", times = "";
        if (Is_An_Huan == 1) {
            times = huanBaoModel.getTimes();
            id = String.valueOf(huanBaoModel.getID());
        } else {
            times = carsInforModel.getTimes();
            id = String.valueOf(carsInforModel.getID());
        }
        UpdateCarStatusModel model = new UpdateCarStatusModel();
        model.setType(0);
        model.setAppearanceInspector(Login_name);
        model.setQueueID(id);
        switch (CHECK_MODE) {
            case 0:
                model.setAppearanceStatus(flag);
                break;
            case 1:
                model.setRoadStatus(flag);
                break;
            case 2:
                model.setDynamicStatus(flag);
                break;
        }
        Gson gson = new Gson();
        jsonStr22 = gson.toJson(model);
        UtilsLog.e("updateCarStatusInfor_anjian---jsonStr==" + jsonStr22);
        String logStr = "\n" + "外检项目更新状态--请求成功--updateCarStatusInfor_anjian" +
                "\n" + "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
                UPDATE_CAR_STATUS + "\n" + "JSON::" + jsonStr22 + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("updateCarStatusInfor_anjian---url==" + SharedPreferencesUtils.getIP(this) + UPDATE_CAR_STATUS);
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + UPDATE_CAR_STATUS)
                .tag(this)
                .upJson(jsonStr22)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body().trim();
                        UtilsLog.e("updateCarStatusInfor_anjian-result==" + result);
                        UtilsLog.e("updateCarStatusInfor_anjian-result=22=" + result.substring(1, result.length() -
                                1));
                        String logStr = "\n" + "外检项目更新状态--请求成功--安检--" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
                                UPDATE_CAR_STATUS + "\n" + "JSON::" + jsonStr22 + "\n" + "result::" +
                                response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("getDataWaiJainStart-onError==" + response.body());
                        String logStr = "\n" + "外检项目更新状态---安检-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
                                UPDATE_CAR_STATUS + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                    }
                });
    }

    /**
     * 更新车辆状态
     * AppearanceStatus 99 项目完成
     */
    private void updateCarStatusInfor_huanbao() {
        UtilsLog.e("更新车辆状态=======环保====");
        UpdateCarStatusModel model = new UpdateCarStatusModel();
        model.setType(1);
        model.setQueueID(String.valueOf(huanBaoModel.getID()));
        model.setAppearanceStatus(1);
        try {
//                    String name = URLDecoder.decode(BaseApplication.accountModelList.get(0).getUserName(),
//                            "UTF-8");
            String name = URLDecoder.decode(Login_name, "UTF-8");
            model.setAppearanceInspector(name);//检测员名字，汉字
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

//        model.setAppearanceInspector(Login_name);
//        model.setDetectionID(carsInforModel.getID());
        Gson gson = new Gson();
        String jsonStr = gson.toJson(model);
        UtilsLog.e("updateCarStatusInfor_huanbao---jsonStr==" + jsonStr);
        String logStr = "\n" + "更新车辆状态--updateCarStatusInfor_huanbao" +
                "\n" + "\n" + "JSON::" + jsonStr +
                "\n" + "url:" + SharedPreferencesUtils.getIP(this) + UPDATE_CAR_STATUS;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("updateCarStatusInfor_huanbao---url==" + SharedPreferencesUtils.getHuanBaoIP(this) + UPDATE_CAR_STATUS);
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + UPDATE_CAR_STATUS)
                .tag(this)
                .upJson(jsonStr)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
//                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                        String result = response.body().trim();
                        UtilsLog.e("updateCarStatusInfor_huanbao-result==" + result);
                        UtilsLog.e("updateCarStatusInfor_huanbao-result=22=" + result.substring(1, result.length()
                                - 1));
                        String str = result.substring(1, result.length() - 1);
                        String logStr = "\n" + "环保-车辆详情--更新车辆状态请求成功--环保--" +
                                "\n" + "result::" + response.body() + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//                        String str = result.substring(1, result.length() - 1);
                        if ("ok".equalsIgnoreCase(str)) {
//                            finish();
                            acAnHuanBtnXiangmuJieshu.setEnabled(true);
                        } else {
                            Toast.makeText(An_Huan_HomeActivity.this, "环保更新车辆状态失败", Toast.LENGTH_LONG)
                                    .show();
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("updateCarStatusInfor_huanbao-onError==" + response.body());
                        String logStr = "\n" + "外检-车辆详情--更新车辆状态请求失败---环保---error" +
                                "\n" + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
                        Toast.makeText(An_Huan_HomeActivity.this, "更新车辆状态失败", Toast.LENGTH_LONG)
                                .show();
                    }
                });
    }

    List<CheckItemModel> list2 = null;

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data != null) {
            UtilsLog.e("onActivityResult=resultCode=" + resultCode);
//            UtilsLog.e("onActivityResult==" + data.getIntExtra("nq", 0));
            switch (resultCode) {
                case 500:
                    list2 = new ArrayList<>();
                    list2 = (List<CheckItemModel>) data.getSerializableExtra("waiJianPhoto_buhege_List");
                    List<MyChoiceModel> waiJianPhoto_List = new ArrayList<>();//Code2选择的列表
                    if (list2 != null && list2.size() > 0) {
                        is_500 = true;
                        List<Item_2Model> Item_2Model_list = new ArrayList<>();//Code2去重后的所有数据
                        Item_2Model item_2 = null;
                        for (int i = 0; i < list2.size(); i++) {
                            item_2 = new Item_2Model();
                            item_2.setID(list2.get(i).getID());
                            item_2.setCode1(list2.get(i).getCode1());
                            item_2.setCode2(list2.get(i).getCode2());
                            item_2.setName2(list2.get(i).getName2());
                            item_2.setFlag(list2.get(i).getFlag());
                            Item_2Model_list.add(item_2);
                        }
                        for (int k = 0; k < Item_2Model_list.size() - 1; k++) {
                            for (int j = Item_2Model_list.size() - 1; j > k; j--) {
                                if (Item_2Model_list.get(j).getCode2().equals(Item_2Model_list.get(k).getCode2())) {
                                    Item_2Model_list.remove(j);
                                }
                            }
                        }

                        for (int i = 0; i < Item_2Model_list.size(); i++) {
                            MyChoiceModel model = new MyChoiceModel();
                            model.setCode2(Item_2Model_list.get(i).getCode2());
                            model.setChecked(true);
                            model.setName2(Item_2Model_list.get(i).getName2());
                            model.setCode_key("Code2-" + Item_2Model_list.get(i).getCode2());
                            model.setCode_values(Item_2Model_list.get(i).getFlag());
                            waiJianPhoto_List.add(model);
                        }
                        upload_code_str_500 = "";
                        for (int i = 0; i < waiJianPhoto_List.size(); i++) {
                            upload_code_str_500 = upload_code_str_500 + "\"" + waiJianPhoto_List.get(i).getCode_key() + "\""
                                    + ":" + "\"" + waiJianPhoto_List.get(i).getCode_values() + "\"" + ",";
                        }
                        if (upload_code_str_500.length() > 0) {
                            upload_code_str_500 = upload_code_str_500.substring(0, upload_code_str_500.length() - 1);
                        }
                        UtilsLog.e("500---list2" + list2.toString());
                        String logStrfw = "\n" + "onActivityResult-111--500---list2" +
                                "\n" + "list2::" + list2.toString() + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                    } else {
                        UtilsLog.e("list2====nulll==");
                        String logStrfw = "\n" + "onActivityResult-222--500---list2" +
                                "\n" + "list2====nulll==" + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                    }
                    UtilsLog.e("list2====upload_code_str==" + upload_code_str_500);
                    String logStrfw = "\n" + "onActivityResult--333-500---upload_code_str_500" +
                            "\n" + "upload_code_str::" + upload_code_str_500 + "\n";
                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                    break;
                case 101:
                    int result_1 = data.getIntExtra("nq", 0);
                    if (result_1 == 1) {
                        NQ_STATEMENT = true;
                    } else {
                        NQ_STATEMENT = false;
                    }
                    break;
                case 102:
                    int result_2 = data.getIntExtra("nq", 0);
                    if (result_2 == 1) {
                        UC_STATEMENT = true;
                    } else {
                        UC_STATEMENT = false;
                    }
                    break;
                case 876:
                    UtilsLog.e("手写签字上传成功--------------");
                    int result_sign = data.getIntExtra("isSign", 0);
                    if (result_sign == 1) {
                        isSign = true;
                    } else {
                        isSign = false;
                    }
                    break;
            }
        }
    }

    AlertDialog.Builder builder = null;

    private void showDialog(String content) {
        AlertDialog.Builder builder = new AlertDialog.Builder
                (An_Huan_HomeActivity.this);
        builder.setTitle("提示");
        builder.setMessage(content);
//        builder.setNegativeButton("取消", null);
        builder.setPositiveButton("确定", null);
        builder.show();
    }

    private void showMyDialog(String[] str, final int id) {
//        BottomMenu bottomMenu= BottomMenu().build(this);
        BottomMenu.show(this, str, new OnMenuItemClickListener() {
            @Override
            public void onClick(String text, int index) {
                //返回参数 text 即菜单名称，index 即菜单索引
                UtilsLog.e("外检---showMyDialog==" + text + "===" + index);
                switch (id) {
                    case R.id.ac_car_air_suspension:
                        //空气悬架
                        acCarAirSuspension.setText(text);
                        break;
                    case R.id.ac_car_suspension_form:
                        //悬架类型
                        acCarSuspensionForm.setText(text);
                        break;
                    case R.id.ac_car_lectronice_handbrake:
                        //电子手刹
                        acCarLectroniceHandbrake.setText(text);
                        break;
                    case R.id.ac_car_is_is_obd:
                        //是否有OBD
                        acCarIsIsObd.setText(text);
                        break;
                }
            }
        }).setMenuTextInfo(new TextInfo().setBold(true).setFontColor(Color.BLACK).setGravity(Gravity.CENTER));
    }

    private void showMyDialog(String[] str) {
        BottomMenu.show(this, str, new OnMenuItemClickListener() {
            @Override
            public void onClick(String text, int index) {
                //返回参数 text 即菜单名称，index 即菜单索引
                UtilsLog.e("路试---showMyDialog==" + text + "===" + index);
                includeAnEtMemo.setText(text);

            }
        }).setMenuTextInfo(new TextInfo().setBold(true).setFontColor(Color.BLACK).setGravity(Gravity.CENTER));
    }

    //上传本地后台
    private void uploadData(WaiJainDataModel waiJainDataModel) {
        Gson gson = new Gson();
        String jsonStr = gson.toJson(waiJainDataModel);
        UtilsLog.e("外检项目--上传本地后台数据---jsonStr==" + jsonStr);
        UtilsLog.e("外检项目--上传本地后台数据---url==" + SharedPreferencesUtils.getIP(this) + REPORTED_DATA);
        String logStr = "\n" + "外检项目--上传本地后台数据---json" + "\n" +
                "json::" + jsonStr + "\n" +
                "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) + REPORTED_DATA;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + REPORTED_DATA).tag(this)
                .upJson(jsonStr)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("外检项目--上传本地后台数据--result==" + result);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("外检项目--上传本地后台数据--newResult==" + newResult);
                        String logStr = "\n" + "外检项目--上传本地后台数据---请求成功" +
                                "\n" + "result::" + result;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//                        if ("ok".equalsIgnoreCase(newResult)) {
////                            Handler handler = new Handler();
////                            handler.postDelayed(new Runnable() {
////                                @Override
////                                public void run() {
////                                    updateCarStatusInfor();
////                                }
////                            }, 800);//后执行Runnable中的run方法
//                        } else {
//                            showDialog("上传本地后台数据失败，请重试");
//                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("外检项目--上传后台数据-onError==" + response.body());
                        String logStr = "\n" + "外检项目--上传本地后台数据--onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(An_Huan_HomeActivity.this) +
                                REPORTED_DATA + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(An_Huan_HomeActivity.this);
//                        showDialog("上传本地后台数据网络异常，请重试");
                    }
                });
    }

    void initJsonDataToPlateform(String finish_time) {
        waiJainDataModel2.setDataType("F1_Memo");
        String memo = includeAnEtMemo.getText().toString().trim();

        waiJainDataModel2.setMemo(memo.equals("无") ? "" : memo);
        waiJainDataModel2.setEngineNOFlag(memo.equals("无") ? "" : memo);
        waiJainDataModel2.setDetection_ID(String.valueOf(carsInforModel.getID()));
        waiJainDataModel2.setGUID(carsInforModel.getGUID());
        waiJainDataModel2.setDetectionDevID(CommonUtils.getIMEI(this));
        waiJainDataModel2.setBrakeForce(carsInforModel.getBrakeForce());
        waiJainDataModel2.setPlateNO(carsInforModel.getPlateRegion() + carsInforModel.getPlateNO());
        waiJainDataModel2.setAirAdmission(carsInforModel.getAirAdmission());
        try {
            String name = URLDecoder.decode(Login_name, "UTF-8");
            waiJainDataModel2.setAppearanceInspector(name);//检测员名字，汉字
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        waiJainDataModel2.setAppearanceNo(login_IDNumber);
        waiJainDataModel2.setApprovedLoad(carsInforModel.getApprovedLoad());
        waiJainDataModel2.setArea(carsInforModel.getArea());
        waiJainDataModel2.setBodyColor(carsInforModel.getBodyColor());
        waiJainDataModel2.setBrand(carsInforModel.getBrand());
        waiJainDataModel2.setCarBodyType(carsInforModel.getCarBodyType());
        waiJainDataModel2.setCarID(carsInforModel.getCarID());
        waiJainDataModel2.setCarModel(carsInforModel.getCarModel());
        waiJainDataModel2.setCarTypeLevel(carsInforModel.getCarTypeLevel());
        waiJainDataModel2.setCategory(carsInforModel.getCategory());
        waiJainDataModel2.setCentralAxle(carsInforModel.getCentralAxle());
        waiJainDataModel2.setCode(carsInforModel.getCode());
        waiJainDataModel2.setCombCarNO(carsInforModel.getCombCarNO());
        waiJainDataModel2.setCurbWeight(carsInforModel.getCurbWeight());
        waiJainDataModel2.setDetectDate(carsInforModel.getDetectDate());
        waiJainDataModel2.setDetectionCategory(carsInforModel.getDetectionCategory());
        waiJainDataModel2.setDetectionStatus(carsInforModel.getDetectionStatus());
        waiJainDataModel2.setDisplacement(carsInforModel.getDisplacement());
        waiJainDataModel2.setDriveAxle(carsInforModel.getDriveAxle());
        waiJainDataModel2.setDriverAxleWeight(carsInforModel.getDriverAxleWeight());
        waiJainDataModel2.setDriverTypeName(carsInforModel.getDriverTypeName());
        waiJainDataModel2.setDriverType(carsInforModel.getDriverType());
        waiJainDataModel2.setPlateType(carsInforModel.getPlateType());
        waiJainDataModel2.setItemcode(Item_Code);
        waiJainDataModel2.setLine(Line);
        waiJainDataModel2.setMainAxis(carsInforModel.getMainAxis());
        waiJainDataModel2.setParkingAxle(carsInforModel.getParkingAxle());
        waiJainDataModel2.setEngineNO(carsInforModel.getEngineNO());
        waiJainDataModel2.setFuelType(carsInforModel.getFuelType());
        waiJainDataModel2.setPlateTypeName(carsInforModel.getPlateTypeName());
        waiJainDataModel2.setPlatformSN(carsInforModel.getPlatformSN());
        waiJainDataModel2.setQueueID(carsInforModel.getQueueID());
        waiJainDataModel2.setSN(carsInforModel.getSN());
        waiJainDataModel2.setStatus(carsInforModel.getStatus());
        waiJainDataModel2.setTest_times(carsInforModel.getTimes());
        waiJainDataModel2.setTimes(carsInforModel.getTimes());
        waiJainDataModel2.setType(carsInforModel.getType());
        waiJainDataModel2.setVIN(carsInforModel.getVIN());
//        waiJainDataModel2.setDataType(Item_Code);
        waiJainDataModel2.setOwner(carsInforModel.getOwner());
        waiJainDataModel2.setTelephone(carsInforModel.getTelephone());
        waiJainDataModel2.setAddress(carsInforModel.getAddress());
        waiJainDataModel2.setStart_Time(BaseApplication.W_ItemStart_time);
        waiJainDataModel2.setFinish_Time(finish_time);
//        waiJainDataModel2.setF1ResultNote("");
        List<WaiJianItemModel> books = WaiJianItemModel.listAll(WaiJianItemModel.class);
        if (books != null && books.size() > 0) {
            String logStr = "\n" + "initJsonDataToPlateform--查询本地数据库--有数据-" +
                    "\n" + "DB::" + books.toString() + "\n";
            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
            UtilsLog.e("WaiJianPhotoActivity----本地数据库查询--2222--不为空==" + books.toString());
            for (int i = 0; i < books.size(); i++) {
                waiJainDataModel2.setWKLength(books.get(i).getWaikuoChang().trim().replaceAll(" ", ""));
                waiJainDataModel2.setWKHeight(books.get(i).getWaikuoGao().trim().replaceAll(" ", ""));
                waiJainDataModel2.setWKWidth(books.get(i).getWaikuoKuan().trim().replaceAll(" ", ""));
                waiJainDataModel2.setWBase(books.get(i).getZhouju().trim().replaceAll(" ", ""));
                waiJainDataModel2.setTurnTireTreadDepth(books.get(i).getDancheZhuanxianglunLuntaiHuawenShendu().trim().replaceAll(" ", ""));
                waiJainDataModel2.setOtherTireTreadDepth(books.get(i).getDancheQtaLuntaiHuawenShendu().trim().replaceAll(" ", ""));
                waiJainDataModel2.setGTireTreadDepth(books.get(i).getGuacheLuntaiHuanwenShendu().trim().replaceAll(" ", ""));
                waiJainDataModel2.setDLiftHeight(books.get(i).getChexiangLanbanGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel2.setGLiftHeight(books.get(i).getGuaCheLanbanGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel2.setFirstAxisLeftHeight(books.get(i).getDiyizhouZuogaodu().trim().replaceAll(" ", ""));
                waiJainDataModel2.setFirstAxisRightHeight(books.get(i).getDiyizhouYougaodu().trim().replaceAll(" ", ""));
                waiJainDataModel2.setFirstAxisHeightDiff(books.get(i).getDiyizhouZuoyouGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel2.setLastAxisLeftHeight(books.get(i).getZuihouzhouZuoGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel2.setLastAxisRightHeight(books.get(i).getZuihouzhouYouGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel2.setLastAxisHeightDiff(books.get(i).getZuihouzhouZuoyouGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel2.setGAxisLeftHeight(books.get(i).getGuaCheZuoGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel2.setGAxisRightHeight(books.get(i).getGuaCheYouGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel2.setGAxisHeightDiff(books.get(i).getGuaCheGaoduGaoducha().trim().replaceAll(" ", ""));
                waiJainDataModel2.setF1ResultNote(books.get(i).getF1ResultNote().trim().replaceAll(" ", ""));
            }
        } else {
            UtilsLog.e("WaiJianPhotoActivity----本地数据库查询--2222--空==");
            String logStr = "\n" + "initJsonDataToPlateform--查询本地数据库--本地数据库查询--2222--空==-" + "\n";
            PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
            if (Integer.valueOf(carsInforModel.getTimes()) > 1 && carsInforModel != null) {
                //转向轴数量
//                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getTurnAxis()))) {
//                    waiJainDataModel.setTurnAxis(carsInforModel.getTurnAxis());
//                }
//                //驻车制动是否使用电子控制装置
//                if (carsInforModel.getElectronicHandbrake().equals("1")) {
//                    waiJainDataModel.setElectronicHandbrake("1");
//                } else {
//                    waiJainDataModel.setElectronicHandbrake("0");
//                }
//                //空气悬架轴
//                //是否配备空气悬架
//                if (carsInforModel.getAirSuspension() == "1") {
//                    waiJainDataModel.setAirSuspension("1");
//                } else {
//                    waiJainDataModel.setAirSuspension("0");
//                }
//                waiJainDataModel.setAirSuspensionAxle(carsInforModel.getAirSuspensionAxle());
//                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getDriverType()))) {
//                    if (carsInforModel.getDriverType().equals("2") ||
//                            carsInforModel.getDriverType().equals("3")) {
//                        waiJainDataModel.setFourWheelDrive("1");
//                    } else {
//                        waiJainDataModel.setFourWheelDrive("0");
//                    }
//                } else {
//                    waiJainDataModel.setFourWheelDrive("0");
//                }
                //            waiJainDataModel.setFourWheelDrive(carsInforModel.getDriverType());
//            TireTreadVerdict 轮胎花纹深度，
//            AxisLeftHeightVerdict 车身对称部位，
//            LiftHeightVerdict 栏板高度
                waiJainDataModel2.setWKLength(TextUtils.isEmpty(carsInforModel.getWKLength()) ? "" : carsInforModel.getWKLength());
                waiJainDataModel2.setWKWidth(TextUtils.isEmpty(carsInforModel.getWKWidth()) ? "" : carsInforModel.getWKWidth());
                waiJainDataModel2.setWKHeight(TextUtils.isEmpty(carsInforModel.getWKHeight()) ? "" : carsInforModel.getWKHeight());
                waiJainDataModel2.setWheelBase(TextUtils.isEmpty(carsInforModel.getWheelBase()) ? "" : carsInforModel.getWheelBase());
                waiJainDataModel2.setTurnTireTreadDepth(TextUtils.isEmpty(carsInforModel.getTurnTireTreadDepth()) ? "" : carsInforModel.getTurnTireTreadDepth());
                waiJainDataModel2.setOtherTireTreadDepth(TextUtils.isEmpty(carsInforModel.getOtherTireTreadDepth()) ? "" : carsInforModel.getOtherTireTreadDepth());
                waiJainDataModel2.setGTireTreadDepth(TextUtils.isEmpty(carsInforModel.getGTireTreadDepth()) ? "" : carsInforModel.getGTireTreadDepth());
                waiJainDataModel2.setGLiftHeight(TextUtils.isEmpty(carsInforModel.getGLiftHeight()) ? "" : carsInforModel.getGLiftHeight());
                waiJainDataModel2.setDLiftHeight(TextUtils.isEmpty(carsInforModel.getDLiftHeight()) ? "" : carsInforModel.getDLiftHeight());
                waiJainDataModel2.setFirstAxisLeftHeight(TextUtils.isEmpty(carsInforModel.getFirstAxisLeftHeight()) ? "" : carsInforModel.getFirstAxisLeftHeight());
                waiJainDataModel2.setFirstAxisRightHeight(TextUtils.isEmpty(carsInforModel.getFirstAxisRightHeight()) ? "" : carsInforModel.getFirstAxisRightHeight());
                waiJainDataModel2.setFirstAxisHeightDiff(TextUtils.isEmpty(carsInforModel.getFirstAxisHeightDiff()) ? "" : carsInforModel.getFirstAxisHeightDiff());
                waiJainDataModel2.setLastAxisLeftHeight(TextUtils.isEmpty(carsInforModel.getLastAxisLeftHeight()) ? "" : carsInforModel.getLastAxisLeftHeight());
                waiJainDataModel2.setLastAxisRightHeight(TextUtils.isEmpty(carsInforModel.getLastAxisRightHeight()) ? "" : carsInforModel.getLastAxisRightHeight());
                waiJainDataModel2.setLastAxisHeightDiff(TextUtils.isEmpty(carsInforModel.getLastAxisHeightDiff()) ? "" : carsInforModel.getLastAxisHeightDiff());
                waiJainDataModel2.setGAxisLeftHeight(TextUtils.isEmpty(carsInforModel.getGAxisLeftHeight()) ? "" : carsInforModel.getGAxisLeftHeight());
                waiJainDataModel2.setGAxisRightHeight(TextUtils.isEmpty(carsInforModel.getGAxisRightHeight()) ? "" : carsInforModel.getGAxisRightHeight());
                waiJainDataModel2.setGAxisHeightDiff(TextUtils.isEmpty(carsInforModel.getGAxisHeightDiff()) ? "" : carsInforModel.getGAxisHeightDiff());
                waiJainDataModel2.setF1ResultNote("");

                waiJainDataModel2.setTireTreadVerdict(TextUtils.isEmpty(carsInforModel.getTireTreadVerdict()) ? "" : carsInforModel.getTireTreadVerdict());
                waiJainDataModel2.setAxisLeftHeightVerdict(TextUtils.isEmpty(carsInforModel.getAxisLeftHeightVerdict()) ? "" : carsInforModel.getAxisLeftHeightVerdict());
                waiJainDataModel2.setLiftHeightVerdict(TextUtils.isEmpty(carsInforModel.getLiftHeightVerdict()) ? "" : carsInforModel.getLiftHeightVerdict());

                String logStrvb = "\n" + "initJsonDataToPlateform--查询本地数据库--本地数据库查询--2222--空==-" + "\n"
                        + "waiJainDataModel2::" + waiJainDataModel2.toString() + "\n";
                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrvb.getBytes());
            }
        }
        UtilsLog.e("WaiJianPhotoActivity----最终数据--waiJainDataModel2==" + waiJainDataModel2.toString());
        String logStrvb = "\n" + "initJsonDataToPlateform--最终数据==-" + "\n"
                + "waiJainDataModel2::" + waiJainDataModel2.toString() + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrvb.getBytes());
        getDataReportData33(waiJainDataModel2);
//        uploadData(waiJainDataModel2);
    }

    String situation = "";

    //手机数据库操作
    String dbModelData(boolean is, boolean f1_resul_tnote) {
        String result = "";
        Gson gson = new Gson();
        WaiJianItemModel model = null;
        WaiJainDataModel waiJainDataModel = null;

        if (Integer.valueOf(carsInforModel.getTimes()) > 1 && carsInforModel != null) {
            //复检
            situation = "数据来源----复检车辆详情数据";
            if (is_db_data) {
                situation += "------本地数据库有数据";
                model = new WaiJianItemModel();
                waiJainDataModel = new WaiJainDataModel();
                List<WaiJianItemModel> books = WaiJianItemModel.listAll(WaiJianItemModel.class);
                UtilsLog.e("dbModelData===" + books.toString());
                if (books == null || books.size() == 0) {
                    return result = "";
                }
                model = books.get(0);
//                waiJainDataModel.setRemark(model.getRemark());
                //转向轴数量
                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getTurnAxis()))) {
                    waiJainDataModel.setTurnAxis(carsInforModel.getTurnAxis());
                }

                if (model.getShifouDianzikongzhi().contains("是")) {
                    waiJainDataModel.setElectronicHandbrake("1");
                } else {
                    waiJainDataModel.setElectronicHandbrake("0");
                }
                if (model.getKongqiXuanjia().contains("是")) {
                    waiJainDataModel.setAirSuspension("1");
                } else {
                    waiJainDataModel.setAirSuspension("0");
                }
                waiJainDataModel.setAirSuspensionAxle(model.getKongqiXuanjiaZhou().replaceAll(" ", ""));
                if (is) {
                    //是否全时/适时四驱
                    waiJainDataModel.setDriverType(model.getShifouQuanshi().replaceAll(" ", ""));
//                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getDriverType()))) {
//                    waiJainDataModel.setDriverType(carsInforModel.getDriverType());
//                }
                } else {

                }

                if (model.getShifouQuanshi().equals("是")) {
                    waiJainDataModel.setFourWheelDrive("1");
                } else {
                    waiJainDataModel.setFourWheelDrive("0");
                }
                waiJainDataModel.setTireTreadVerdict(model.getHege_luntai());
                waiJainDataModel.setAxisLeftHeightVerdict(model.getHege_cheshen());
                waiJainDataModel.setLiftHeightVerdict(model.getHege_lanban());
                waiJainDataModel.setWKLength(model.getWaikuoChang().trim().replaceAll(" ", ""));
                waiJainDataModel.setWKWidth(model.getWaikuoKuan().trim().replaceAll(" ", ""));
                waiJainDataModel.setWKHeight(model.getWaikuoGao().trim().replaceAll(" ", ""));
                waiJainDataModel.setDLiftHeight(model.getChexiangLanbanGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setTurnTireTreadDepth(model.getDancheZhuanxianglunLuntaiHuawenShendu().trim().replaceAll(" ", ""));
                waiJainDataModel.setOtherTireTreadDepth(model.getDancheQtaLuntaiHuawenShendu().trim().replaceAll(" ", ""));
                waiJainDataModel.setGLiftHeight(model.getGuaCheLanbanGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setGTireTreadDepth(model.getGuacheLuntaiHuanwenShendu().trim().replaceAll(" ", ""));
                waiJainDataModel.setFirstAxisLeftHeight(model.getDiyizhouZuogaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setFirstAxisRightHeight(model.getDiyizhouYougaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setFirstAxisHeightDiff(model.getDiyizhouZuoyouGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setLastAxisLeftHeight(model.getZuihouzhouZuoGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setLastAxisRightHeight(model.getZuihouzhouYouGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setLastAxisHeightDiff(model.getZuihouzhouZuoyouGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setGAxisLeftHeight(model.getGuaCheZuoGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setGAxisRightHeight(model.getGuaCheYouGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setGAxisHeightDiff(model.getGuaCheGaoduGaoducha().trim().replaceAll(" ", ""));
                waiJainDataModel.setWheelBase(model.getZhouju().trim().replaceAll(" ", ""));
                if (f1_resul_tnote) {
                    waiJainDataModel.setF1ResultNote(model.getF1ResultNote().trim().replaceAll(" ", ""));
                } else {

                }
                result = gson.toJson(waiJainDataModel);
                String logStr = "\n" + "外检----dbModelData---" +
                        "\n" + situation + "\n" + "result::" + result + "\n";
                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
            } else {
                situation += "------用车辆本身的数据，本地数据库没有数据";
                waiJainDataModel = new WaiJainDataModel();
//                waiJainDataModel.setRemark("");
                //转向轴数量
                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getTurnAxis()))) {
                    waiJainDataModel.setTurnAxis(carsInforModel.getTurnAxis());
                }
                //驻车制动是否使用电子控制装置
                if (carsInforModel.getElectronicHandbrake().equals("1")) {
                    waiJainDataModel.setElectronicHandbrake("1");
                } else {
                    waiJainDataModel.setElectronicHandbrake("0");
                }
                //空气悬架轴
                //是否配备空气悬架
                if (carsInforModel.getAirSuspension() == "1") {
                    waiJainDataModel.setAirSuspension("1");
                } else {
                    waiJainDataModel.setAirSuspension("0");
                }
                waiJainDataModel.setAirSuspensionAxle(carsInforModel.getAirSuspensionAxle());
                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getDriverType()))) {
                    if (carsInforModel.getDriverType().equals("2") ||
                            carsInforModel.getDriverType().equals("3")) {
                        waiJainDataModel.setFourWheelDrive("1");
                    } else {
                        waiJainDataModel.setFourWheelDrive("0");
                    }
                } else {
                    waiJainDataModel.setFourWheelDrive("0");
                }
                //            waiJainDataModel.setFourWheelDrive(carsInforModel.getDriverType());
//            TireTreadVerdict 轮胎花纹深度，
//            AxisLeftHeightVerdict 车身对称部位，
//            LiftHeightVerdict 栏板高度
                waiJainDataModel.setTireTreadVerdict(TextUtils.isEmpty(carsInforModel.getTireTreadVerdict()) ? "" : carsInforModel.getTireTreadVerdict());
                waiJainDataModel.setAxisLeftHeightVerdict(TextUtils.isEmpty(carsInforModel.getAxisLeftHeightVerdict()) ? "" : carsInforModel.getAxisLeftHeightVerdict());
                waiJainDataModel.setLiftHeightVerdict(TextUtils.isEmpty(carsInforModel.getLiftHeightVerdict()) ? "" : carsInforModel.getLiftHeightVerdict());
                waiJainDataModel.setWKLength(TextUtils.isEmpty(carsInforModel.getWKLength()) ? "" : carsInforModel.getWKLength());
                waiJainDataModel.setWKWidth(TextUtils.isEmpty(carsInforModel.getWKWidth()) ? "" : carsInforModel.getWKWidth());
                waiJainDataModel.setWKHeight(TextUtils.isEmpty(carsInforModel.getWKHeight()) ? "" : carsInforModel.getWKHeight());
                waiJainDataModel.setDLiftHeight(TextUtils.isEmpty(carsInforModel.getDLiftHeight()) ? "" : carsInforModel.getDLiftHeight());
                waiJainDataModel.setTurnTireTreadDepth(TextUtils.isEmpty(carsInforModel.getTurnTireTreadDepth()) ? "" : carsInforModel.getTurnTireTreadDepth());
                waiJainDataModel.setOtherTireTreadDepth(TextUtils.isEmpty(carsInforModel.getOtherTireTreadDepth()) ? "" : carsInforModel.getOtherTireTreadDepth());
                waiJainDataModel.setGLiftHeight(TextUtils.isEmpty(carsInforModel.getGLiftHeight()) ? "" : carsInforModel.getGLiftHeight());
                waiJainDataModel.setGTireTreadDepth(TextUtils.isEmpty(carsInforModel.getGTireTreadDepth()) ? "" : carsInforModel.getGTireTreadDepth());
                waiJainDataModel.setFirstAxisLeftHeight(TextUtils.isEmpty(carsInforModel.getFirstAxisLeftHeight()) ? "" : carsInforModel.getFirstAxisLeftHeight());
                waiJainDataModel.setFirstAxisRightHeight(TextUtils.isEmpty(carsInforModel.getFirstAxisRightHeight()) ? "" : carsInforModel.getFirstAxisRightHeight());
                waiJainDataModel.setFirstAxisHeightDiff(TextUtils.isEmpty(carsInforModel.getFirstAxisHeightDiff()) ? "" : carsInforModel.getFirstAxisHeightDiff());
                waiJainDataModel.setLastAxisLeftHeight(TextUtils.isEmpty(carsInforModel.getLastAxisLeftHeight()) ? "" : carsInforModel.getLastAxisLeftHeight());
                waiJainDataModel.setLastAxisRightHeight(TextUtils.isEmpty(carsInforModel.getLastAxisRightHeight()) ? "" : carsInforModel.getLastAxisRightHeight());
                waiJainDataModel.setLastAxisHeightDiff(TextUtils.isEmpty(carsInforModel.getLastAxisHeightDiff()) ? "" : carsInforModel.getLastAxisHeightDiff());
                waiJainDataModel.setGAxisLeftHeight(TextUtils.isEmpty(carsInforModel.getGAxisLeftHeight()) ? "" : carsInforModel.getGAxisLeftHeight());
                waiJainDataModel.setGAxisRightHeight(TextUtils.isEmpty(carsInforModel.getGAxisRightHeight()) ? "" : carsInforModel.getGAxisRightHeight());
                waiJainDataModel.setGAxisHeightDiff(TextUtils.isEmpty(carsInforModel.getGAxisHeightDiff()) ? "" : carsInforModel.getGAxisHeightDiff());
                waiJainDataModel.setWheelBase(TextUtils.isEmpty(carsInforModel.getWheelBase()) ? "" : carsInforModel.getWheelBase());
                if (f1_resul_tnote) {
                    waiJainDataModel.setF1ResultNote("");
                } else {

                }
                result = gson.toJson(waiJainDataModel);
                Log.e("tag", "数据来源为复检数据，result==22222222222==" + result + "=====" + result);
                String logStr = "\n" + "外检----dbModelData---" +
                        "\n" + situation + "\n" + "result::" + result + "\n";
                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//            waiJainDataModel.setF1ResultNote("");
                //是否全时/适时四驱
//                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getDriverType()))) {
//                    if (carsInforModel.getDriverType().equals("2") ||
//                            carsInforModel.getDriverType().equals("3")) {
//                        waiJainDataModel.setFourWheelDrive("1");
//                    } else {
//                        waiJainDataModel.setFourWheelDrive("0");
//                    }
//                } else {
//                    waiJainDataModel.setFourWheelDrive("0");
//                }
//                result = gson.toJson(waiJainDataModel);
            }

        } else {
            if (is_db_data) {
                situation = "初检---数据来源----本地数据库";
                model = new WaiJianItemModel();
                waiJainDataModel = new WaiJainDataModel();
                List<WaiJianItemModel> books = WaiJianItemModel.listAll(WaiJianItemModel.class);
                UtilsLog.e("dbModelData===" + books.toString());
                if (books == null || books.size() == 0) {
                    return result = "";
                }
                model = books.get(0);
//            if(Is_An_Huan==0||Is_An_Huan==2){
                //转向轴数量
                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getTurnAxis()))) {
                    waiJainDataModel.setTurnAxis(carsInforModel.getTurnAxis());
                }
                //驻车制动是否使用电子控制装置
//            if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getElectronicHandbrake()))) {
//                waiJainDataModel.setElectronicHandbrake(
//                        carsInforModel.getElectronicHandbrake().equals("1") ? "1" : "0");
//            }
                //空气悬架轴
//            waiJainDataModel.setAirSuspensionAxle(carsInforModel.getAirSuspensionAxle());
                //是否配备空气悬架
//            waiJainDataModel.setAirSuspension(carsInforModel.getAirSuspension().equals("1") ? "1" : "0");

                if (model.getShifouDianzikongzhi().contains("是")) {
                    waiJainDataModel.setElectronicHandbrake("1");
                } else {
                    waiJainDataModel.setElectronicHandbrake("0");
                }
                if (model.getKongqiXuanjia().contains("是")) {
                    waiJainDataModel.setAirSuspension("1");
                } else {
                    waiJainDataModel.setAirSuspension("0");
                }
                waiJainDataModel.setAirSuspensionAxle(model.getKongqiXuanjiaZhou().replaceAll(" ", ""));


                if (is) {
                    //是否全时/适时四驱
                    waiJainDataModel.setDriverType(model.getShifouQuanshi().replaceAll(" ", ""));
//                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getDriverType()))) {
//                    waiJainDataModel.setDriverType(carsInforModel.getDriverType());
//                }
                } else {

                }
//            }else{
//                //转向轴数量
//                if (!TextUtils.isEmpty(String.valueOf(huanBaoModel.getTurnAxis()))) {
//                    waiJainDataModel.setTurnAxis(huanBaoModel.getTurnAxis());
//                }
//                //驻车制动是否使用电子控制装置
//                if (!TextUtils.isEmpty(String.valueOf(huanBaoModel.getElectronicHandbrake()))) {
//                    waiJainDataModel.setElectronicHandbrake(
//                            huanBaoModel.getElectronicHandbrake().equals("1") ? "1" : "0");
//                }
//                //空气悬架轴
//                waiJainDataModel.setAirSuspensionAxle(huanBaoModel.getAirSuspensionAxle());
//                //是否配备空气悬架
//                waiJainDataModel.setAirSuspension(huanBaoModel.getAirSuspension().equals("1") ? "1" : "0");
//
//                if (is) {
//                    //是否全时/适时四驱
//                    if (!TextUtils.isEmpty(String.valueOf(huanBaoModel.getDriverType()))) {
//                        waiJainDataModel.setDriverType(huanBaoModel.getDriverType());
//                    }
//                } else {
//
//                }
//            }

                if (model.getShifouQuanshi().equals("是")) {
                    waiJainDataModel.setFourWheelDrive("1");
                } else {
                    waiJainDataModel.setFourWheelDrive("0");
                }
                waiJainDataModel.setTireTreadVerdict(model.getHege_luntai());
                waiJainDataModel.setAxisLeftHeightVerdict(model.getHege_cheshen());
                waiJainDataModel.setLiftHeightVerdict(model.getHege_lanban());
                waiJainDataModel.setWKLength(model.getWaikuoChang().trim().replaceAll(" ", ""));
                waiJainDataModel.setWKWidth(model.getWaikuoKuan().trim().replaceAll(" ", ""));
                waiJainDataModel.setWKHeight(model.getWaikuoGao().trim().replaceAll(" ", ""));
                waiJainDataModel.setDLiftHeight(model.getChexiangLanbanGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setTurnTireTreadDepth(model.getDancheZhuanxianglunLuntaiHuawenShendu().trim().replaceAll(" ", ""));
                waiJainDataModel.setOtherTireTreadDepth(model.getDancheQtaLuntaiHuawenShendu().trim().replaceAll(" ", ""));
                waiJainDataModel.setGLiftHeight(model.getGuaCheLanbanGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setGTireTreadDepth(model.getGuacheLuntaiHuanwenShendu().trim().replaceAll(" ", ""));
                waiJainDataModel.setFirstAxisLeftHeight(model.getDiyizhouZuogaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setFirstAxisRightHeight(model.getDiyizhouYougaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setFirstAxisHeightDiff(model.getDiyizhouZuoyouGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setLastAxisLeftHeight(model.getZuihouzhouZuoGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setLastAxisRightHeight(model.getZuihouzhouYouGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setLastAxisHeightDiff(model.getZuihouzhouZuoyouGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setGAxisLeftHeight(model.getGuaCheZuoGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setGAxisRightHeight(model.getGuaCheYouGaodu().trim().replaceAll(" ", ""));
                waiJainDataModel.setGAxisHeightDiff(model.getGuaCheGaoduGaoducha().trim().replaceAll(" ", ""));
                waiJainDataModel.setWheelBase(model.getZhouju().trim().replaceAll(" ", ""));
                if (f1_resul_tnote) {
                    waiJainDataModel.setF1ResultNote(model.getF1ResultNote().trim().replaceAll(" ", ""));
                } else {

                }
                result = gson.toJson(waiJainDataModel);
                String logStr = "\n" + "外检----dbModelData---" +
                        "\n" + situation + "\n" + "result::" + result + "\n";
                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
            } else {
                situation = "初检---数据来源----默认数据---------33333333333333--------";
                waiJainDataModel = new WaiJainDataModel();
                //转向轴数量
                waiJainDataModel.setTurnAxis("1");
//            if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getTurnAxis()))) {
//                waiJainDataModel.setTurnAxis(carsInforModel.getTurnAxis());
//            }
                //驻车制动是否使用电子控制装置
//            waiJainDataModel.setElectronicHandbrake("0");
                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getElectronicHandbrake()))) {
                    waiJainDataModel.setElectronicHandbrake(
                            carsInforModel.getElectronicHandbrake().equals("1") ? "1" : "0");
                }
                //空气悬架轴
                waiJainDataModel.setAirSuspensionAxle("");
//            waiJainDataModel.setAirSuspensionAxle(carsInforModel.getAirSuspensionAxle());
                //是否配备空气悬架
                waiJainDataModel.setAirSuspension("0");
//            waiJainDataModel.setAirSuspension(carsInforModel.getAirSuspension().equals("1") ? "1" : "0");
                if (is) {
                    //是否全时/适时四驱
                    waiJainDataModel.setDriverType("0");
//                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getDriverType()))) {
//                    waiJainDataModel.setDriverType(carsInforModel.getDriverType());
//                }
                } else {

                }
                waiJainDataModel.setTireTreadVerdict("合格");
                waiJainDataModel.setAxisLeftHeightVerdict("合格");
                waiJainDataModel.setLiftHeightVerdict("合格");
                waiJainDataModel.setWKLength("");
                waiJainDataModel.setWKWidth("");
                waiJainDataModel.setWKHeight("");
                waiJainDataModel.setDLiftHeight("");
                waiJainDataModel.setTurnTireTreadDepth("");
                waiJainDataModel.setOtherTireTreadDepth("");
                waiJainDataModel.setGLiftHeight("");
                waiJainDataModel.setGTireTreadDepth("");
                waiJainDataModel.setFirstAxisLeftHeight("");
                waiJainDataModel.setFirstAxisRightHeight("");
                waiJainDataModel.setFirstAxisHeightDiff("");
                waiJainDataModel.setLastAxisLeftHeight("");
                waiJainDataModel.setLastAxisRightHeight("");
                waiJainDataModel.setLastAxisHeightDiff("");
                waiJainDataModel.setGAxisLeftHeight("");
                waiJainDataModel.setGAxisRightHeight("");
                waiJainDataModel.setGAxisHeightDiff("");
                waiJainDataModel.setWheelBase("");
                if (f1_resul_tnote) {
                    waiJainDataModel.setF1ResultNote("");
                } else {

                }
//            waiJainDataModel.setF1ResultNote("");
                //是否全时/适时四驱
                if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getDriverType()))) {
                    if (carsInforModel.getDriverType().equals("2") ||
                            carsInforModel.getDriverType().equals("3")) {
                        waiJainDataModel.setFourWheelDrive("1");
                    } else {
                        waiJainDataModel.setFourWheelDrive("0");
                    }
                } else {
                    waiJainDataModel.setFourWheelDrive("0");
                }
                result = gson.toJson(waiJainDataModel);
                String logStr = "\n" + "外检----dbModelData---" +
                        "\n" + situation + "\n" + "result::" + result + "\n";
                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
            }
        }
        UtilsLog.e("dbModelData---json==" + result);
//        UtilsLog.e("dbModelData---json=111=" + result.substring(1, result.length() - 1));
        return result.substring(1, result.length() - 1).replaceAll(" ", "");
    }

    //外检不合格项目--自动提交数据--F1_record
    private List<Item_2Model> an_huan_Item_2Model_list = new ArrayList<>();//Code2去重后的所有数据
    private List<WaiJianAddRecordModel> an_huan_WaiJianAddRecordModelList = new ArrayList<>();//外检增加记录list
    private List<Group> an_huan_groupList = new ArrayList<Group>();
    private List<Object> an_huan_gridList = new ArrayList<Object>();

    void initData2() {
        UtilsLog.e("initData2=======");
        List<Item_1Model> Item_1Model_list = new ArrayList<>();
        Item_1Model item_1 = null;
        for (int i = 0; i < mycar_checkItemlList.size(); i++) {
            item_1 = new Item_1Model();
            item_1.setID(mycar_checkItemlList.get(i).getID());
            item_1.setCode1(mycar_checkItemlList.get(i).getCode1());
            item_1.setName1(mycar_checkItemlList.get(i).getName1());
            Item_1Model_list.add(item_1);
        }
        for (int k = 0; k < Item_1Model_list.size() - 1; k++) {
            for (int j = Item_1Model_list.size() - 1; j > k; j--) {
                if (Item_1Model_list.get(j).getCode1().equals(Item_1Model_list.get(k).getCode1())) {
                    Item_1Model_list.remove(j);
                }
            }
        }

        Item_2Model item_2 = null;
        for (int i = 0; i < mycar_checkItemlList.size(); i++) {
            item_2 = new Item_2Model();
            item_2.setID(mycar_checkItemlList.get(i).getID());
            item_2.setCode1(mycar_checkItemlList.get(i).getCode1());
            item_2.setCode2(mycar_checkItemlList.get(i).getCode2());
            item_2.setName2(mycar_checkItemlList.get(i).getName2());
            item_2.setFlag(mycar_checkItemlList.get(i).getFlag());
            an_huan_Item_2Model_list.add(item_2);
        }
        for (int k = 0; k < an_huan_Item_2Model_list.size() - 1; k++) {
            for (int j = an_huan_Item_2Model_list.size() - 1; j > k; j--) {
                if (an_huan_Item_2Model_list.get(j).getCode2().equals(an_huan_Item_2Model_list.get(k).getCode2())) {
                    an_huan_Item_2Model_list.remove(j);
                }
            }
        }

        for (int i = 0; i < Item_1Model_list.size(); i++) {
            Group group = new Group();
            group.setID(Item_1Model_list.get(i).getID());
            group.setCode1(Item_1Model_list.get(i).getCode1());
            group.setName(Item_1Model_list.get(i).getName1());
            group.setChecked(false);

            List<City> cityList = new ArrayList<City>();

            if (i < an_huan_Item_2Model_list.size()) {
                for (int j = 0; j < an_huan_Item_2Model_list.size(); j++) {

                    if (group.getCode1().equals(an_huan_Item_2Model_list.get(j).getCode1())) {
                        City city = new City();
                        city.setID(an_huan_Item_2Model_list.get(j).getID());
                        city.setCode1(an_huan_Item_2Model_list.get(j).getCode1());
                        city.setCode2(an_huan_Item_2Model_list.get(j).getCode2());
                        city.setName2(an_huan_Item_2Model_list.get(j).getName2());
                        city.setName(an_huan_Item_2Model_list.get(j).getName2());
//                        city.setFlag(an_huan_Item_2Model_list.get(j).getFlag());
                        if (!TextUtils.isEmpty(an_huan_Item_2Model_list.get(j).getFlag()) && an_huan_Item_2Model_list.get(j).getFlag() != "null") {
                            city.setFlag(an_huan_Item_2Model_list.get(j).getFlag());
                        } else {
                            city.setFlag("0");
                        }
                        city.setIsChange(0);
                        if (an_huan_Item_2Model_list.get(j).getFlag() != null) {
//                            Flag --0:不检测 1：检测
                            if (Integer.valueOf(an_huan_Item_2Model_list.get(j).getFlag()) == 0) {
                                city.setChecked(false);
                            } else {
                                city.setChecked(true);
                            }
                        }
//                        city.setChecked(true);
                        cityList.add(city);
                        city.addObserver(group);
                        group.addObserver(city);
                    }
                }
            }
            if (cityList != null && cityList.size() > 0) {
                group.setCityList(cityList);
            }
            an_huan_groupList.add(group);
        }
//        UtilsLog.e("an_huan_groupList=======" + an_huan_groupList.toString());
    }

    private void setDataModel() {
        if (an_huan_WaiJianAddRecordModelList != null) {
            an_huan_WaiJianAddRecordModelList.clear();
        }
        an_huan_WaiJianAddRecordModelList = new ArrayList<>();
        if (an_huan_groupList != null && an_huan_groupList.size() > 0) {
            for (int i = 0; i < an_huan_groupList.size(); i++) {
                List<City> cityList = an_huan_groupList.get(i).getCityList();
                for (int j = 0; j < cityList.size(); j++) {
//                    if (cityList.get(j).getIsChange() == 1) {
                    WaiJianAddRecordModel model = new WaiJianAddRecordModel();
                    model.setDataType("F1_Record");
                    model.setDetection_ID(String.valueOf(carsInforModel.getID()));
                    model.setGUID(carsInforModel.getGUID());
                    model.setTimes(carsInforModel.getTimes());
                    model.setUnqualified_Code1(cityList.get(j).getCode1());
                    model.setUnqualified_Code2(cityList.get(j).getCode2());
                    if (cityList.get(j).getName2().contains("轮胎")) {
                        model.setVerdict("1");
                    } else {
                        model.setVerdict(cityList.get(j).getFlag());
                    }

                    an_huan_WaiJianAddRecordModelList.add(model);
//                    }
                }
            }
        }
        String logStr = "\n" + "An_Huan_HomeActivity--外检不合格项目-增加外检记录接口--setDataModel" +
                "\n" + "WaiJianAddRecordModelList::" + an_huan_WaiJianAddRecordModelList.toString() + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//        UtilsLog.e("An_Huan_HomeActivity--WaiJianAddRecordModelList==" + an_huan_WaiJianAddRecordModelList.toString());
    }

    //外检不合格项目-增加外检记录接口
    private void uploadDataByWaiJianItem() {

        Gson gson = new Gson();
        String jsonStr = gson.toJson(an_huan_WaiJianAddRecordModelList);
        UtilsLog.e("An_Huan_HomeActivity--uploadDataByWaiJianItem---jsonStr==" + jsonStr);
        UtilsLog.e("An_Huan_HomeActivity--uploadDataByWaiJianItem---url==" + SharedPreferencesUtils.getIP(this) + WAIJIAN_ADD_RECORED);
        String logStr = "\n" + "An_Huan_HomeActivity--外检不合格项目-增加外检记录接口--uploadDataByWaiJianItem--请求" +
                "\n" + "URL::" + SharedPreferencesUtils.getIP(this) +
                WAIJIAN_ADD_RECORED + "\n" + "JSON::" + jsonStr + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + WAIJIAN_ADD_RECORED).tag(this)
                .upJson(jsonStr)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("An_Huan_HomeActivity--uploadDataByWaiJianItem-result==" + result);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("An_Huan_HomeActivity--uploadDataByWaiJianItem-newResult==" + newResult);
                        String logStrf = "\n" + "An_Huan_HomeActivity--外检不合格项目-增加外检记录接口--uploadDataByWaiJianItem--请求成功" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("An_Huan_HomeActivity--uploadDataByWaiJianItem-onError==" + response.body());
                        String logStr = "\n" + "An_Huan_HomeActivity--外检不合格项目-增加外检记录接口--uploadDataByWaiJianItem-onError-失败" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                    }
                });
    }


}
